TTL command return value change

69 views
Skip to first unread message

Salvatore Sanfilippo

unread,
Nov 10, 2012, 6:47:35 AM11/10/12
to Redis DB
Hi list,

currently the TTL command returns -1 on non existing key, and also in
the case no expire time is set on the key at all.

Starting with Redis 2.8 I would like to change the behavior into the following:

Key without TTL -> -1
Non existing key TTL -> -2

I don't think this is going to break a lot of code at all, but I
wonder what you think. This API makes sense as to have the old
behavior you need just:

if ttl(key) < 0, instead of explicitly checking for -1

Instead in order to distinguish the two other different cases, just
check for the proper value, that your client library could declare as
constants for simplicity.

About the sequence -1 and -2, the rationale is that -1 no TTL and -2
no key at all is in accordance with the fact that -2 feels "more
negative" than -1, so it is easy to remember.

Cheers,
Salvatore

--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org

Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
— David Gelernter

Sergei Tulentsev

unread,
Nov 10, 2012, 9:52:27 AM11/10/12
to redi...@googlegroups.com
This won't break any of my code. And it seems like a good idea. :)



--
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.




--
Best regards,
Sergei Tulentsev

Hikeonpast

unread,
Nov 12, 2012, 1:11:45 PM11/12/12
to redi...@googlegroups.com
This would be awesome.  We end up pipelining EXISTS and TTL on a bunch of reads to work around the current limitation.  Your proposed implementation is great from our perspective.

Is there any chance that this might be back-ported to 2.6? :)

Cheers,

Dean


Salvatore Sanfilippo

unread,
Nov 12, 2012, 1:52:46 PM11/12/12
to Redis DB
On Mon, Nov 12, 2012 at 7:11 PM, Hikeonpast <deanw...@gmail.com> wrote:

> Is there any chance that this might be back-ported to 2.6? :)

Sorry we can't break 2.6 API... but the change is in line for 2.8 :-)
Reply all
Reply to author
Forward
0 new messages