A
A
Artcifra2015-12-14 18:18:51
Yii
Artcifra, 2015-12-14 18:18:51

How to do grouping of Redis cache keys in Yii 1.1?

There is a task to clear the cache when updating the data, but not all but certain groups of
classes

  • https://github.com/phpredis/phpredis
  • https://github.com/phpnode/YiiRedis

do not provide the ability to delete by mask
by mask, you can find keys, but you can’t delete it like that with a large database
redis->delete(redis->keys('mymask*'))

Tell me how to save the data so that you can use 3 levels of separation, the first level, (I will use the base available 9 pcs is enough)
  1. by types (structures, templates, sql, etc.)
  2. by cities (sites)
  3. by common key (for example, all news or menus)
  4. record key

the question is how to save it, so that later it would be possible to delete not only by the last field, but by specifying 2 and 3 or only 2?
I thought, maybe if there is such an opportunity, by selecting a group, set the old date for it?
or maybe there is the same method as from the command line for Redis

redis-cli KEYS "prefix:*" | xargs redis-cli DEL
$ redis-cli --raw keys "$PATTERN" | xargs redis-cli del

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vyachin, 2016-06-13
@vyachin

work in a mask in a radish is BUT it is not recommended. There is an interesting key invalidation tool in yii2 www.yiiframework.com/doc-2.0/yii-caching-tagdepend... , something similar can be easily implemented for yii1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question