As you noted :
is a reserved character in the PSR-6 cache standard, which Symfony's cache component builds on.
If you want to keep them in your code, you could write an adapter that takes your keys and replaces the :
with something else before passing it to the regular cache.
So for example you could write an adapter that looks something like this:
class MyCacheAdapter implements AdapterInterface
{
private $decoratedAdapter;
public function __construct(AdapterInterface $adapter)
{
$this->decoratedAdapter = $adapter;
}
public function getItem($key): CacheItemInterface
{
$key = str_replace(':', '.', $key);
return $this->decoratedAdapter->getItem($key);
}
...
}
For all other methods you can just proxy the call to the decorated service and return the result. It's a bit annoying to write, but the interface demands it.
In your service configuration you can configure it like this:
services:
App\Cache\MyCacheAdapter:
decorates: 'Symfony\Component\Cache\Adapter\RedisAdapter'
arguments:
$adapter: '@app.cache.adapter.redis'
This configuration is only a rough outline both argument and the class names might have to be adjusted. In any case with this service decoration your adapter wraps around the original redis adapter and then when you configure it to be used by the cache component it should work fine, that your existing keys like some:cache:key25
will be converted to some.cache.key25
before they are passed into the cache component, so before the error message happens.