SETEX and DEL and EXISTS

102 views
Skip to first unread message

Robert DiFalco

unread,
Dec 6, 2013, 4:57:28 PM12/6/13
to redi...@googlegroups.com
I notice that when I SETEX a key, what for it to expire and then call DEL that 1 is returned for that key. But if I called EXISTS instead then as I expect it is 0. Is this intended behavior? I would expect EXISTS and DEL to give the same result.

Thanks!

Matt Palmer

unread,
Dec 6, 2013, 8:56:16 PM12/6/13
to redi...@googlegroups.com
I agree with you -- my naive assumption would be that EXISTS and DEL on a
single key, if executed at the same time on identical datasets, should
return the same result.

Interestingly, the DEL and EXISTS docs make no mention of key expiry, but
the docs for EXPIRE mention DEL almost in passing:

The timeout is cleared only when the key is removed using the DEL command

That reads to me a little bit like DEL acts on the key before its expiry is
considered, but it's still ambiguous enough to matter.

It's a trivial thing to patch, if it is deemed that the semantics of EXISTS
and DEL should be the same in the face of key expiry -- just need to chuck
expireIfNeeded(c->db,c->argv[j]) before the call to dbDelete in delCommand.
If you feel like shooting to get your name in the commit logs, you could put
up a pull request and see where it goes.

- Matt

--
Well-designed presentation software would, when the user chooses any
transition other than "dissolve", put up a dialog box saying "You are a
jerk. Press OK to continue."
-- Simon Cozens, in a place that doesn't exist

Robert DiFalco

unread,
Oct 2, 2014, 5:23:53 PM10/2/14
to redi...@googlegroups.com, mpa...@hezmatt.org
Has this been fixed lately? I cannot reproduce this issue with the latest REDIS but I cannot see it being addressed in any of the change logs. I can remove calls to EXISTS before DEL if this has been addressed but I'm not sure if I am just getting lucky in not being able to reproduce it. 

Robert DiFalco

unread,
Oct 2, 2014, 5:32:56 PM10/2/14
to redi...@googlegroups.com, mpa...@hezmatt.org
Found it, 2.8.10.

Josiah Carlson

unread,
Oct 3, 2014, 12:23:45 AM10/3/14
to redi...@googlegroups.com, mpa...@hezmatt.org
As a P.S. you probably shouldn't run Redis 2.8.10 in particular if you have a choice (I know of at least one bug with Lua scripting in that specific release that breaks some 3rd party libraries), stick with the most recent 2.8 release (2.8.17 at present).

 - Josiah

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

Reply all
Reply to author
Forward
0 new messages