Sha256: 2b15aff56e62ff3a7a5e9e6d0c3f832f421fca1e286d995e7e91fcd3d5b49065
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
class Redis module Helpers # These are core commands that all types share (rename, etc) module CoreCommands def exists? redis.exists key end # Delete key. Redis: DEL def delete redis.del key end alias_method :del, :delete alias_method :clear, :delete def type redis.type key end 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 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 def expire(seconds) redis.expire key, seconds end def expireat(unixtime) redis.expireat key, unixtime end def persist redis.persist key end def ttl redis.ttl(@key) end def move(dbindex) redis.move key, dbindex end def serializer options[:serializer] || Marshal end 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 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis-objects-1.5.0 | lib/redis/helpers/core_commands.rb |