trying to use Redis with tagging in my Symfony 5 app but can't seem to get RedisTagAwareAdapter to work. Saving to Redis without tags works just fine like this:
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Contracts\Cache\ItemInterface;
$client = RedisAdapter::createConnection(
'redis://redis'
);
$cache = new RedisAdapter($client);
$key = "testkey";
$data = "hello world";
$cacheItem = $cache->getItem($key);
$cacheItem->set($data);
$cacheItem->expiresAfter(3600);
$cache->save($cacheItem);
But if I switch to using the RedisTagAwareAdapter as this suggests then nothing gets saved:
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
use Symfony\Contracts\Cache\ItemInterface;
$client = RedisAdapter::createConnection(
'redis://redis'
);
$cache = new RedisTagAwareAdapter($client);
$key = "testkey";
$data = "hello world";
$cacheItem = $cache->getItem($key);
$cacheItem->set($data);
$cacheItem->tag('greeting');
$cacheItem->expiresAfter(3600);
$cache->save($cacheItem);
the $cache->save() returns false. No other errors are thrown.
I'm using Symfony 5, Redis server version 6.2.5 and have phpredis installed. Any ideas on what I'm doing wrong? TIA