0

project configuration : symfony 5.

I configured my cache to use redis, in config\packages\cache.yml like this

framework:
    cache:
        prefix_seed: myAppPrefix_
        app: cache.adapter.redis
        system: cache.adapter.filesystem
        default_redis_provider: '%env(REDIS_URL)%'

When i run php bin/console cache:clear --env=dev, redis keys are not deleted and they are not expired.

The cache:clear command is not supposed to remove or make the keys expired ?

I can i delete all my keys, matching my App prefix ?

Thanks for your help

Ersoy
  • 8,816
  • 6
  • 34
  • 48
pop_up
  • 1,451
  • 2
  • 18
  • 35
  • Did you check redis with `dbsize` or `info memory` ? probably your config is missing (not familiar with symfony). You may try `redis-cli monitor` to see the executed methods. If there is not `flushall` or `flushdb` then you need to check the your redis configuration. – Ersoy Jul 01 '20 at 12:32
  • i don't want a flushall because redis is share with other applications. I must delete only the key matching my prefix. I just don't understand if symfony is supposed to do something or not in redis when i run cache:clear. Does it works for you ? – pop_up Jul 02 '20 at 07:33
  • I think it may not have that feature(laravel doesn't) but you may check the answers posted here https://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-using-redis - i used them many times for similar cases to yours – Ersoy Jul 02 '20 at 07:54

1 Answers1

1

I don't find any references confirming that cache:clear is supposed to clear redis keys linked to my configuration.

Finaly, i created a command (injecting "AdapterInterface") to clean them with that code :

public function __construct(AdapterInterface $cache)
{
    ...
    $this->cache= $cache;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
    $this->redis->clear();
}

Be careful, on windows it doesn't works because redis version is empty in RedisTrait:356

pop_up
  • 1,451
  • 2
  • 18
  • 35