Back to Deployer

Cachetool Recipe

docs/contrib/cachetool.md

8.0.35.2 KB
Original Source
<!-- DO NOT EDIT THIS FILE! --> <!-- Instead edit contrib/cachetool.php --> <!-- Then run bin/docgen -->

Cachetool Recipe

php
require 'contrib/cachetool.php';

Source

Configuration

  • cachetool (optional): accepts a string or an array of strings with the unix socket or ip address to php-fpm. If cachetool is not given, then the application will look for a configuration file. The file must be named .cachetool.yml or .cachetool.yaml. CacheTool will look for this file on the current directory and in any parent directory until it finds one. If the paths above fail it will try to load /etc/cachetool.yml or /etc/cachetool.yaml configuration file.
    php
    set('cachetool', '/var/run/php-fpm.sock');
    // or
    set('cachetool', '127.0.0.1:9000');
    // or
    set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock']);
    

You can also specify different cachetool settings for each host:

php
host('staging')
    ->set('cachetool', '127.0.0.1:9000');
host('production')
    ->set('cachetool', '/var/run/php-fpm.sock');

By default, if no cachetool parameter is provided, this recipe will fallback to the global setting. If your deployment user does not have permission to access the php-fpm.sock, you can alternatively use the web adapter that creates a temporary php file and makes a web request to it with a configuration like

php
set('cachetool_args', '--web --web-path=./public --web-url=https://{{hostname}}');

Usage

Since APCu and OPcache deal with compiling and caching files, they should be executed right after the symlink is created for the new release:

php
after('deploy:symlink', 'cachetool:clear:opcache');
or
after('deploy:symlink', 'cachetool:clear:apcu');

Read more

Read more information about cachetool on the website: http://gordalina.github.io/cachetool/

Configuration

cachetool

Source

Configuration

  • cachetool (optional): accepts a string or an array of strings with the unix socket or ip address to php-fpm. If cachetool is not given, then the application will look for a configuration file. The file must be named .cachetool.yml or .cachetool.yaml. CacheTool will look for this file on the current directory and in any parent directory until it finds one. If the paths above fail it will try to load /etc/cachetool.yml or /etc/cachetool.yaml configuration file.
    php
    set('cachetool', '/var/run/php-fpm.sock');
    // or
    set('cachetool', '127.0.0.1:9000');
    // or
    set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock']);
    

You can also specify different cachetool settings for each host:

php
host('staging')
    ->set('cachetool', '127.0.0.1:9000');
host('production')
    ->set('cachetool', '/var/run/php-fpm.sock');

By default, if no cachetool parameter is provided, this recipe will fallback to the global setting. If your deployment user does not have permission to access the php-fpm.sock, you can alternatively use the web adapter that creates a temporary php file and makes a web request to it with a configuration like

php
set('cachetool_args', '--web --web-path=./public --web-url=https://{{hostname}}');

Usage

Since APCu and OPcache deal with compiling and caching files, they should be executed right after the symlink is created for the new release:

php
after('deploy:symlink', 'cachetool:clear:opcache');
or
after('deploy:symlink', 'cachetool:clear:apcu');

Read more

Read more information about cachetool on the website: http://gordalina.github.io/cachetool/

cachetool_url

Source

URL to download cachetool from if it is not available

CacheTool 9.x works with PHP >=8.1 CacheTool 8.x works with PHP >=8.0 CacheTool 7.x works with PHP >=7.3

php
'https://github.com/gordalina/cachetool/releases/download/9.1.0/cachetool.phar'

cachetool_args

Source

bin/cachetool

Source

php
if (!test('[ -f {{release_or_current_path}}/cachetool.phar ]')) {
run("cd {{release_or_current_path}} && curl -sLO {{cachetool_url}}");
}
return '{{release_or_current_path}}/cachetool.phar';

cachetool_options

Source

:::info Autogenerated The value of this configuration is autogenerated on access. :::

Tasks

cachetool:clear:opcache {#cachetool-clear-opcache}

Source

Clears OPcode cache.

Clear opcache cache

cachetool:clear:apcu {#cachetool-clear-apcu}

Source

Clears APCu system cache.

Clear APCu cache

cachetool:clear:stat {#cachetool-clear-stat}

Source

Clears file status and realpath caches.

Clear file status cache, including the realpath cache