Now there seems to be inconsistency from the view of the redis-check redis-clean and redis-clean-old-version
yaml
Shopsys\FrameworkBundle\Command\CheckRedisCommand:
arguments:
$cacheClients:
- '@snc_redis.bestselling_products'
- '@snc_redis.doctrine_metadata'
- '@snc_redis.doctrine_query'
- '@snc_redis.session'
# missing framework_annotations
php
foreach ($this->cacheClients as $cacheClient) {
try {
$cacheClient->ping();
yaml
Shopsys\FrameworkBundle\Component\Redis\RedisFacade:
arguments:
$cacheClients:
- '@snc_redis.bestselling_products'
- '@snc_redis.doctrine_metadata'
- '@snc_redis.doctrine_query'
php
$this->redisFacade->cleanCache();
foreach ($this->cacheClients as $redis) {
$prefix = (string)$redis->getOption(Redis::OPT_PREFIX);
$pattern = $prefix . '*';
if (!$this->hasAnyKey($redis, $pattern)) {
continue;
}
$redis->eval("return redis.call('del', unpack(redis.call('keys', ARGV[1])))", [$pattern]);
}
RedisCleanCacheOldCommand
Shopsys\FrameworkBundle\Component\Redis\RedisVersionsFacade:
arguments:
$globalClient: '@snc_redis.global'
$currentVersion: '%build-version%'
```php
$this->redisVersionsFacade->cleanOldCache();
do {
$keys = $this->globalClient->scan($iterator, $versionPattern);
if ($keys !== false) {
$toRemove = [];
foreach ($keys as $key) {
if (strpos($key, $currentVersionPrefix) === false) {
$keyWithoutPrefix = substr($key, strlen($prefix));
$toRemove[] = $keyWithoutPrefix;
}
}
$this->globalClient->unlink($toRemove);
```
As we can see from the check and clean commands, redis cache client can be stored on different redis servers, but as for the redis-clean-old-version removing of old cache is done just via global client.
Second thing is that if someone wants to implement new cache like Twig, there seems to be no cookbook that tells what framework services should be overriden with new set of cache clients.
There is a reason redis-clean and redis-clean-old-version differ. Regular cleaning is using the version prefix clients but when you need to clean old versions, you have to use "unprefixed" client, and that is the global client. But once prefixed (version) clients are on different servers, then.... yes, it will be a problem :thinking:
This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because there was no acivity within the last half a year.
Most helpful comment
There is a reason
redis-cleanandredis-clean-old-versiondiffer. Regular cleaning is using theversionprefix clients but when you need to clean old versions, you have to use "unprefixed" client, and that is the global client. But once prefixed (version) clients are on different servers, then.... yes, it will be a problem :thinking: