@@ -329,8 +329,15 @@ def expireat(key, unix_time)
329
329
# Get the time to live (in seconds) for a key.
330
330
#
331
331
# @param [String] key
332
- # @return [Fixnum] remaining time to live in seconds, or -1 if the
333
- # key does not exist or does not have a timeout
332
+ # @return [Fixnum] remaining time to live in seconds.
333
+ #
334
+ # In Redis 2.6 or older the command returns -1 if the key does not exist or if
335
+ # the key exist but has no associated expire.
336
+ #
337
+ # Starting with Redis 2.8 the return value in case of error changed:
338
+ #
339
+ # - The command returns -2 if the key does not exist.
340
+ # - The command returns -1 if the key exists but has no associated expire.
334
341
def ttl ( key )
335
342
synchronize do |client |
336
343
client . call ( [ :ttl , key ] )
@@ -362,8 +369,14 @@ def pexpireat(key, ms_unix_time)
362
369
# Get the time to live (in milliseconds) for a key.
363
370
#
364
371
# @param [String] key
365
- # @return [Fixnum] remaining time to live in milliseconds, or -1 if the
366
- # key does not exist or does not have a timeout
372
+ # @return [Fixnum] remaining time to live in milliseconds
373
+ # In Redis 2.6 or older the command returns -1 if the key does not exist or if
374
+ # the key exist but has no associated expire.
375
+ #
376
+ # Starting with Redis 2.8 the return value in case of error changed:
377
+ #
378
+ # - The command returns -2 if the key does not exist.
379
+ # - The command returns -1 if the key exists but has no associated expire.
367
380
def pttl ( key )
368
381
synchronize do |client |
369
382
client . call ( [ :pttl , key ] )
0 commit comments