class RDB::Dumpers::AOF
Constants
- REDIS_AOF_REWRITE_ITEMS_PER_CMD
Public Instance Methods
buffer_full?(state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 107 def buffer_full?(state) state.info[:buffer].length == REDIS_AOF_REWRITE_ITEMS_PER_CMD end
buffer_some?(state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 103 def buffer_some?(state) state.info[:buffer].length > 0 end
end_hash(key, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 70 def end_hash(key, state) flush(:hmset, state) end
end_list(key, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 34 def end_list(key, state) flush(:rpush, state) end
end_set(key, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 46 def end_set(key, state) flush(:sadd, state) end
end_sortedset(key, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 58 def end_sortedset(key, state) flush(:zadd, state) end
flush(command, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 83 def flush(command, state) if buffer_some?(state) self << serialize_command(command, [state.key] + state.info[:buffer].flatten) reset_buffer(state) end end
handle(command, state, key, *arguments)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 74 def handle(command, state, key, *arguments) if variadic? state.info[:buffer].push(arguments) flush(command, state) if buffer_full?(state) else self << serialize_command(command, [key, *arguments]) end end
hset(key, field, value, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 66 def hset(key, field, value, state) handle(variadic? ? :hmset : :hset, state, key, field, value) end
pexpireat(key, expiration, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 12 def pexpireat(key, expiration, state) command = if state.info[:precision] == :second expiration = (expiration / 1000).to_i :pexpire else :pexpireat end self << serialize_command(command, [key, expiration]) end
reset_buffer(state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 99 def reset_buffer(state) state.info[:buffer] = []; end
rpush(key, member, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 30 def rpush(key, member, state) handle(:rpush, state, key, member) end
sadd(key, member, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 42 def sadd(key, member, state) handle(:sadd, state, key, member) end
serialize_command(command, arguments)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 90 def serialize_command(command, arguments) buffer = "*#{arguments.length + 1}\r\n$#{command.length}\r\n#{command.upcase}\r\n" buffer << arguments.map { |arg| "$#{arg.to_s.length}\r\n#{arg}\r\n" }.join end
set(key, value, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 22 def set(key, value, state) self << serialize_command(:set, [key, value]) end
start_database(database)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 8 def start_database(database) self << serialize_command(:select, [database]) end
start_hash(key, length, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 62 def start_hash(key, length, state) reset_buffer(state) end
start_list(key, length, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 26 def start_list(key, length, state) reset_buffer(state) end
start_set(key, length, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 38 def start_set(key, length, state) reset_buffer(state) end
start_sortedset(key, length, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 50 def start_sortedset(key, length, state) reset_buffer(state) end
variadic?()
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 95 def variadic? @options[:variadic] ||= false end
zadd(key, score, member, state)
click to toggle source
# File lib/rdb/dumpers/aof.rb, line 54 def zadd(key, score, member, state) handle(:zadd, state, key, score, member) end