2013-12-19

SSDB 1.6.7 supports key expiration(TTL)

Views: 19299 | 6 Comments

Since SSDB 1.6.7, the key expiration(TTL) feature is supported. You can set a value to a key, with a time to live. After this time, the will be automatically deleted. With this feature, you can use SSDB as a persistent cache service.

Usage:

$ssdb->setx('key', 'value', 60);

The code above set key=value, and key will be expired after 60 seconds.

Download SSDB NoSQL database: https://github.com/ideawu/ssdb

Posted by ideawu at 2013-12-19 13:46:06 Tags: , ,

6 Responses to "SSDB 1.6.7 supports key expiration(TTL)"

  • hello, ideawu, have the Java API about setx(TTL)? Reply
    @will: Hi, the Java API doesn’t have a method called setx(), but you can use request() to execute any command that ssdb supports. Reply
  • Can you explain how this feature is implemented?
    Is there a separate threads that remove expired items?
    Is there a priority queue (or heap) for storing expiring keys (and finding the key with nearest expire time)?
    Expire times are checked on key retrieving?
    How much overhead does this feature have? (In term of disk storage, disk io, cpu time, memory)
    Does this feature have a performance impact on users/keys that doesn’t use expire time?
    Does the longer TTL have different processing overhead over small TTLs? (or vice-versa) Reply
    @Taha: Hi, there is a separate thread that remove expired items, a zset holds key=>expiration_time pairs sorted by expiration time. Reply
  • Good news! It is very useful feature. Very few NoSQL databases support TTL.

    Is it possible to add hsetx(name, key, value, ttl) operation for hashmap keys?

    Thank you! Reply
    @Egor: Thank you for your advice, I will think of it later. Reply

Leave a Comment