module Redis::Helpers::CoreCommands
These are core commands that all types share (rename, etc)
Public Instance Methods
delete()
click to toggle source
Delete key. Redis: DEL
# File lib/redis/helpers/core_commands.rb, line 14 def delete redis.del key end
exists()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 5 def exists redis.exists key end
exists?()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 9 def exists? redis.exists? key end
expire(seconds)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 38 def expire(seconds) redis.expire key, seconds end
expireat(unixtime)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 42 def expireat(unixtime) redis.expireat key, unixtime end
marshal(value, domarshal=false)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 62 def marshal(value, domarshal=false) if options[:marshal] || domarshal dump_args = options[:marshal_dump_args] || [] serializer.dump(value, *(dump_args.is_a?(Array) ? dump_args : [dump_args])) else value end end
move(dbindex)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 54 def move(dbindex) redis.move key, dbindex end
persist()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 46 def persist redis.persist key end
rename(name, setkey=true)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 24 def rename(name, setkey=true) dest = name.is_a?(self.class) ? name.key : name ret = redis.rename key, dest @key = dest if ret && setkey ret end
renamenx(name, setkey=true)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 31 def renamenx(name, setkey=true) dest = name.is_a?(self.class) ? name.key : name ret = redis.renamenx key, dest @key = dest if ret && setkey ret end
serializer()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 58 def serializer options[:serializer] || Marshal end
ttl()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 50 def ttl redis.ttl(@key) end
type()
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 20 def type redis.type key end
unmarshal(value, domarshal=false)
click to toggle source
# File lib/redis/helpers/core_commands.rb, line 71 def unmarshal(value, domarshal=false) if value.nil? nil elsif options[:marshal] || domarshal if value.is_a?(Array) value.map{|v| unmarshal(v, domarshal)} elsif !value.is_a?(String) value else load_args = options[:marshal_load_args] || [] serializer.load(value, *(load_args.is_a?(Array) ? load_args : [load_args])) end else value end end