Я хочу отключить кеширование результатов в процессе разработки.Отключить кеш результата (Redis) на Dev Env - Symfony2
Я не хочу комментировать коды кэширования или удалять их во время работы на en env.
Есть ли способ отключить кеширование на dev env?
Я использую SNCRedisBundle & Predis для Symfony2 с Redis.
Примеров одиночных результирующие код:
$em = $this->container->get('doctrine')->getManager();
$predis = new \Snc\RedisBundle\Doctrine\Cache\RedisCache();
$predis->setRedis(new \Predis\Client());
$qb = $em->createQueryBuilder();
$qb
->select('s')
->from('CSSliderBundle:Slider', 's')
->where($qb->expr()->eq('s.title', ':title'))
->setParameter('title', $title);
$slider = $qb
->getQuery()
->useResultCache(true, 3600 * 1.5) // added this line
->setResultCacheDriver($predis)
->setResultCacheLifetime(86400)
->getOneOrNullResult();
И второй вопрос:
Есть ли способ очистить кэш-память после вставки/обновления с доктриной встроенной? Я знаю, что я могу использовать lifecycleevents но я интересно, если любой другой вариант доступен ...
Полный конфиг:
snc_redis:
clients:
default:
type: predis
alias: default
dsn: redis://localhost
logging: %kernel.debug%
options:
prefix: "%redis_prefix%"
cache:
type: predis
alias: cache
dsn: redis://localhost/1
logging: true
options:
prefix: "%redis_prefix%"
cluster:
type: predis
alias: cluster
dsn:
- redis://127.0.0.1/2
- redis://127.0.0.2/3
- redis://[email protected]/var/run/redis/redis-1.sock/4
- redis://127.0.0.1:6379/5
options:
profile: 2.4
connection_timeout: 10
connection_persistent: true
read_write_timeout: 30
iterable_multibulk: false
throw_errors: true
cluster: Snc\RedisBundle\Client\Predis\Connection\PredisCluster
monolog:
type: predis
alias: monolog
dsn: redis://localhost/6
logging: false
options:
connection_persistent: true
session:
client: default
use_as_default: true
doctrine:
metadata_cache:
client: cache
entity_manager: default
document_manager: default
result_cache:
client: cache
entity_manager: default
namespace: "doctrine_result_cache_%kernel.environment%_"
query_cache:
client: cache
entity_manager: default
monolog:
client: monolog
key: monolog
swiftmailer:
client: default
key: swiftmailer
Не работает ... Еще один результат после того, как я добавил запись ... –
@ R.CanserYanbakan, используйте '$ query-> useResultCache (true, 3600 * 1.5);' для вашего запроса. –
Bro, я обновляю свой вопрос с помощью вашего кода, но все равно не работаю ... –