Do Redis deletes least used data automatically?

3,241 views
Skip to first unread message

Jamil Shehzad

unread,
Oct 9, 2014, 11:58:27 AM10/9/14
to redi...@googlegroups.com
Hi just want to ask a simple thing.

If i have 1000 keys in redis and all of these keys have an expiry time of 1 year. Now if only 100 keys are being used in past few months. Will redis delete the unused keys automatically or i will have to make some changes in configuration??

New to redis so asking this.

Regards

Itamar Haber

unread,
Oct 9, 2014, 12:50:28 PM10/9/14
to redi...@googlegroups.com
Redis will expire the keys according to their TTL. If you're just reading these 100 keys, the TTL won't change so all 1000 will expire in a year regardless.

Redis **will not** delete anything automatically, but it may evict keys if it runs out of memory. By default, Redis is configured to use as much RAM as it needs (the maxmemory directive) so in in such cases the OS kills it before it evicts anything. To prevent that set maxmemory in the redis.conf file so once memory consumption reaches that value, the defined eviction policy will kick into place. By default, volatile-lru is the used so Redis will prefer evicting keys out of the less-used 900 keys.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief Developers Advocate
Redis Watch Newsletter - Editor and Janitor
Redis Labs - Enterprise-Class Redis for Developers

Mobile: +1 (415) 688 2443
Mobile (IL): +972 (54) 567 9692
Email: ita...@redislabs.com
Skype: itamar.haber

Blog  |  Twitter  |  LinkedIn


Jamil Shehzad

unread,
Oct 9, 2014, 12:54:36 PM10/9/14
to redi...@googlegroups.com



 

Hi i am setting expiry time of each key in my redis data. So should i go for volatile-lru or i should go for allkey-lru? 

 

Plus: What we mean by maxmemory-samples? If i have thousands of keys then what value should i set for this maxmemory-samples?


Thanks for your reply

Itamar Haber

unread,
Oct 9, 2014, 1:03:16 PM10/9/14
to redi...@googlegroups.com
The result should be the same for allkeys- and volatile-lru if all keys have TTLs - perhaps one or the other is marginally more efficient but I wouldn't fret about it.

Re. maxmemory-samples - just because the setting is there, doesn't mean you need to change it ;) I recommend you read this for more background on using Redis as an LRU cache: http://redis.io/topics/lru-cache

Jamil Shehzad

unread,
Oct 9, 2014, 1:20:48 PM10/9/14
to redi...@googlegroups.com


Yes i have read the link provided by you. But i want to ask that whats the purpose of this maxmemory-samples and how does it works?

Josiah Carlson

unread,
Oct 9, 2014, 5:31:11 PM10/9/14
to redi...@googlegroups.com
Salvatore describes the algorithm in some later posts here: https://groups.google.com/forum/#!topic/redis-db/8IPIceL6cGo

 - Josiah

Reply all
Reply to author
Forward
0 new messages