Using redis like memcache where it replaces least used and expires

7,478 views
Skip to first unread message

S Ahmed

unread,
Apr 24, 2011, 9:27:55 PM4/24/11
to redi...@googlegroups.com
I want to simplify my framework stack and just use redis instead of having to use both redis + memcached.

Now this is the first time me using either, but what I liked about memcached is (or rather how I think memcached works!) is that I can allocate say 5 GB of memory, and then just add things to the cache, and it will overrite keys in the cache if they are not being references often (LRU).

I read somewhere that redis can mimick this behavior.

I couldn't find a suitable page on redis.io about this....


Mikhail Mikheev

unread,
Apr 25, 2011, 3:15:05 AM4/25/11
to Redis DB

S Ahmed

unread,
Apr 25, 2011, 9:37:28 PM4/25/11
to redi...@googlegroups.com
So have these config settings changed??  Is this in the docs somewhere seeing as we are in 2.2.5

  • volatile-lru remove a key among the ones with an expire set, trying to remove keys not recently used.
  • volatile-ttl remove a key among the ones with an expire set, trying to remove keys with short remaining time to live.
  • volatile-random remove a random key among the ones with an expire set.
  • allkeys-lru like volatile-lru, but will remove every kind of key, both normal keys or keys with an expire set.
  • allkeys-random like volatile-random, but will remove every kind of keys, both normal keys and keys with an expire set.

Is there one that matches closely to what memcached does?


On Mon, Apr 25, 2011 at 3:15 AM, Mikhail Mikheev <michail...@mail.ru> wrote:

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.


Mikhail Mikheev

unread,
Apr 26, 2011, 2:23:36 AM4/26/11
to Redis DB
> So have these config settings changed??  Is this in the docs somewhere
> seeing as we are in 2.2.5

Actually i don't know if there are any changes in expiration policies
in 2.2.5 as i'm still on 2.2.2. And i'm not sure whether the document
that describes them exists. But usually all the settings are described
in redis.conf file. For most settings it contains detailed
description.

> Is there one that matches closely to what memcached does?
I think you need allkeys-lru to make Redis act as memcached. AFAIK
memcached uses lru policy for every key it stores.

The only difference in Redis here is that it is possible to allow only
volatile keys be expired and keep other keys persistent in memory.
That is, in Redis all values doesn't expire on default until you
explicitly set time to live with command EXPIRE. Such keys for that
time to live is defined are called volatile. In some cases it can be
useful. For example you have a few keys that should never expire (e.g.
lookups or some resources that are not changed and you should be able
to read them fast at any time) so you can use policy volatile-lru to
make sure these keys will never be evicted. But if you decide to use
volatile-lru you should do it with care because if there are too many
keys that will never expire they may consume all the memory and there
will be no room to store volatile keys.
Reply all
Reply to author
Forward
0 new messages