Sha256: 721ca280d4d7a1466e66a98184f29db4fb480a469ebbcb0bea4752b6622cd92e
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
class Redis module Helpers # These are core commands that all types share (rename, etc) module CoreCommands def exists? redis.exists key end 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 sort(options={}) options[:order] = "asc alpha" if options.keys.count == 0 # compat with Ruby val = redis.sort(key, options) val.is_a?(Array) ? val.map{|v| unmarshal(v)} : val end def marshal(value, domarshal=false) if options[:marshal] || domarshal Marshal.dump(value) else value end end def unmarshal(value, domarshal=false) if value.nil? nil elsif options[:marshal] || domarshal Marshal.load(value) else value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redis-objects-1.0.0 | lib/redis/helpers/core_commands.rb |
redis-objects-0.9.1 | lib/redis/helpers/core_commands.rb |