0

Today I got a problem while develop my project.

For example I put some data like blog posts to memcache in by cache key = post_list_OFFSET_LIMIT, where offset and limit it's dynamic data by pagination.

But I can't clear cache by prefix post_list_ when I adding new post. New post will be shown after cache expiration.

Memcache doesn't has feature by tagging. Tagging support can be added by custom code. Does redis has this feature? Tagging or remove tags by prefix?

Thanks.

trauma
  • 312
  • 5
  • 16

1 Answers1

1

You can solve in 3 ways in redis:

  1. Use SCAN command : http://redis.io/commands/scan to get the keys matching your pattern and delete them. How to atomically delete keys matching a pattern using Redis
  2. Set expiry time to keys. http://redis.io/commands/expire. So it gets expired (deleted) after it has lived for it's time.
  3. Set the eviction policy as lru, http://redis.io/topics/lru-cache. So that redis itself deletes old keys when the new keys need the space. This works if and only if you use redis as cache alone.
Community
  • 1
  • 1
Karthikeyan Gopall
  • 5,469
  • 2
  • 19
  • 35