Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions contrib/cachetool.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

## Configuration

- **cachetool** *(optional)*: accepts a *string* with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there.
- **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 `cachetool.yml` file and read the configuration from there.

```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:
Expand Down Expand Up @@ -62,38 +64,50 @@
return '{{release_or_current_path}}/cachetool.phar';
});
set('cachetool_options', function () {
$options = get('cachetool');
$fullOptions = get('cachetool_args');

if (strlen($fullOptions) > 0) {
$options = "{$fullOptions}";
} elseif (strlen($options) > 0) {
$options = "--fcgi={$options}";
$options = (array)get('cachetool');
$fullOptions = (string)get('cachetool_args');
$return = [];

if ($fullOptions !== '') {
$return = [$fullOptions];
} elseif (count($options) > 0) {
foreach ($options as $option) {
$return[] = "--fcgi={$option}";
}
}

return $options;
return $return;
});

/**
* Clear opcache cache
*/
desc('Clears OPcode cache');
task('cachetool:clear:opcache', function () {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} opcache:reset {{cachetool_options}}");
$options = get('cachetool_options');
foreach ($options as $option) {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} opcache:reset $option");
}
});

/**
* Clear APCU cache
*/
desc('Clears APCu system cache');
task('cachetool:clear:apcu', function () {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} apcu:cache:clear {{cachetool_options}}");
$options = get('cachetool_options');
foreach ($options as $option) {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} apcu:cache:clear $option");
}
});

/**
* Clear file status cache, including the realpath cache
*/
desc('Clears file status and realpath caches');
task('cachetool:clear:stat', function () {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} stat:clear {{cachetool_options}}");
$options = get('cachetool_options');
foreach ($options as $option) {
run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} stat:clear $option");
}
});
20 changes: 11 additions & 9 deletions docs/contrib/cachetool.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ require 'contrib/cachetool.php';

## Configuration

- **cachetool** *(optional)*: accepts a *string* with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there.
- **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 `cachetool.yml` file and read the configuration from there.

```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:
Expand Down Expand Up @@ -58,14 +60,14 @@ http://gordalina.github.io/cachetool/

## Configuration
### cachetool
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L48)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L50)





### cachetool_url
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L56)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L58)

URL to download cachetool from if it is not available

Expand All @@ -79,14 +81,14 @@ CacheTool 7.x works with PHP >=7.3


### cachetool_args
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L57)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L59)





### bin/cachetool
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L58)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L60)



Expand All @@ -99,7 +101,7 @@ return '{{release_or_current_path}}/cachetool.phar';


### cachetool_options
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L64)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L66)


:::info Autogenerated
Expand All @@ -113,23 +115,23 @@ The value of this configuration is autogenerated on access.
## Tasks

### cachetool:clear:opcache
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L81)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L86)

Clears OPcode cache.

Clear opcache cache


### cachetool:clear:apcu
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L89)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L97)

Clears APCu system cache.

Clear APCU cache


### cachetool:clear:stat
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L97)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L108)

Clears file status and realpath caches.

Expand Down