Skip to content

Commit e92720f

Browse files
committed
#23 - Add default options for Cache in ClearcacheTask
1 parent 2cb1b76 commit e92720f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

cli/tasks/ClearcacheTask.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Phalcon\Cache;
1616
use Phalcon\Cli\Task as PhTask;
17+
use Phalcon\Config;
1718
use RecursiveDirectoryIterator;
1819
use RecursiveIteratorIterator;
1920
use function in_array;
@@ -24,6 +25,7 @@
2425
* Class ClearcacheTask
2526
*
2627
* @property Cache $cache
28+
* @property Config $config
2729
*/
2830
class ClearcacheTask extends PhTask
2931
{
@@ -76,9 +78,27 @@ private function clearFileCache()
7678
private function clearMemCached()
7779
{
7880
echo 'Clearing data cache' . PHP_EOL;
79-
$options = [];
80-
if (isset($this->getDI()->getShared('config')->get('cache')->options->libmemcached)) {
81-
$options = $this->getDI()->getShared('config')->get('cache')->options->libmemcached;
81+
82+
$default = [
83+
'servers' => [
84+
0 => [
85+
'host' => '127.0.0.1',
86+
'port' => 11211,
87+
'weight' => 100,
88+
],
89+
],
90+
'client' => [
91+
\Memcached::OPT_PREFIX_KEY => 'api-',
92+
],
93+
'lifetime' => 86400,
94+
'prefix' => 'data-',
95+
];
96+
97+
$options = $this->config->path('cache.options.libmemcached', null);
98+
if (true !== empty($options)) {
99+
$options = $options->toArray();
100+
} else {
101+
$options = $default;
82102
}
83103

84104
$servers = $options['servers'] ?? [];

0 commit comments

Comments
 (0)