Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RedisCache delete/clear not working anymore #39280

Closed
@wiseguy1394

Description

@wiseguy1394

Symfony version(s) affected: 5.2.0

Description
Since updating to Symfony 5.2.0 the redis cache delete command seems to be not working anymore.
Also the command bin/console cache:pool:clear [pool] is not working for RedisCache-pools.

How to reproduce
Redis Version 3.2.12

namespace App\Cache;

use Symfony\Component\Cache\Adapter\AdapterInterface;

class TestCache
{
    /**
     * @var AdapterInterface
     */
    private $cache;
    
    public function __construct(AdapterInterface $adapter)
    {
        $this->cache = $adapter;
    }
    
    public function testCache():void
    {
        try {
            $cacheItem = $this->cache->getItem('testKey');
            $cacheItem->set(['testData']);
            $this->cache->save($cacheItem);
                
            dump($this->cache->hasItem('testKey')); // true

            $this->cache->deleteItem('testKey');

            dump($this->cache->hasItem('testKey')); // true
        } catch (\Psr\Cache\InvalidArgumentException $e) {
        }
   }
}

Additional context
We found that there was the following change:
symfony/cache@2cb6631

Because of CentOS 7 we are fixed to Redis Version 3.2.12-2.el7. The UNLINK Command is not available in this redis version and the following if-statement seems not to match.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions