Permalink
Browse files

Pass the actual resolution of the expiration time of keys in `state.i…

…nfo`.
  • Loading branch information...
1 parent bc11af1 commit 67c53ebe9787e6f1c4e83d5d72c3ec7955f02a2b @nrk committed Mar 28, 2012
Showing with 9 additions and 4 deletions.
  1. +7 −4 lib/rdb/dumpers/aof.rb
  2. +2 −0 lib/rdb/reader.rb
View
@@ -1,8 +1,5 @@
module RDB
module Dumpers
- #
- # TODO: PEXPIREAT is supported only for Redis >= 2.6
- #
class AOF
include Dumper
@@ -13,7 +10,13 @@ def start_database(database)
end
def pexpireat(key, expiration, state)
- self << serialize_command(:pexpireat, [key, expiration])
+ command = if state.info[:precision] == :second
+ expiration = (expiration / 1000).to_i
+ :pexpire
+ else
+ :pexpireat
+ end
+ self << serialize_command(command, [key, expiration])
end
def set(key, value, state)
View
@@ -22,10 +22,12 @@ def read(rdb, options = {})
case state.key_type_id
when Opcode::EXPIRETIME_MS
state.key_expiration = rdb.read(8).unpack('Q').first
+ state.info[:precision] = :millisecond
state.key_type_id = rdb.readbyte
when Opcode::EXPIRETIME
state.key_expiration = rdb.read(4).unpack('L').first * 1000
+ state.info[:precision] = :second
state.key_type_id = rdb.readbyte
when Opcode::SELECTDB

0 comments on commit 67c53eb

Please sign in to comment.