I am trying to configure Symfony 3.1 cache using Redis. I follow this guide:
https://symfony.com/blog/new-in-symfony-3-1-cache-component
I installed predis / predis and SncRedisBundle.
In my config.yml I put
framework:
cache:
app: cache.adapter.redis
default_redis_provider: redis://192.168.34.10
snc_redis:
clients:
default:
type: predis
alias: default
dsn: redis://192.168.34.10
logging: %kernel.debug%
cache:
type: predis
alias: cache
dsn: redis://192.168.34.10
logging: %kernel.debug%
options:
connection_timeout: 10
read_write_timeout: 30
Now when I try to access redis through snc_redis, it works fine. But when I try to use the cache component:
public function getLoggedUserAcl($userId)
{
$cachedResources = $this->cacheAdapter->getItem('acl.rules');
$cachedResources->expiresAfter(100);
if ($cachedResources->isHit()) {
dump('hit');
$resources = $cachedResources->get();
} else {
dump('not-hit');
$resources = $this->api->getCollection(Resource::class, null, null, [
'userId' => $userId
]);
$cachedResources->set($resources);
}
return $resources;
}
CacheAdapter is this @cache.app.
Resets all the time NOT_HIT. There is nothing about REDIS in the magazines.
Could you tell me where I was wrong, or give me a hint, what could be wrong?
source
share