Last active
January 12, 2018 21:58
-
-
Save ydnar/59095235190c3db081e178fad011db06 to your computer and use it in GitHub Desktop.
Lua one-liner to implement an “EXPIRENX” command in Redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEL example.com | |
HSET example.com status reserved | |
EVAL "return redis.call('TTL',KEYS[1])>0 or redis.call('EXPIRE',KEYS[1],ARGV[1])" 1 example.com 111111 | |
HGETALL example.com | |
TTL example.com | |
HSET example.com comment IANA | |
EVAL "return redis.call('TTL',KEYS[1])>0 or redis.call('EXPIRE',KEYS[1],ARGV[1])" 1 example.com 222222 | |
HGETALL example.com | |
TTL example.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment