Sha256: 59705b449ca0475853a6de9a5c6256685666052db720fb1388a3ff18e7321445
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
class Redis # # Class representing a simple value. You can use standard Ruby operations on it. # class Value require 'redis/serialize' include Redis::Serialize attr_reader :key, :options, :redis def initialize(key, redis=$redis, options={}) @key = key @redis = redis @options = options @redis.setnx(key, @options[:default]) if @options[:default] end def value=(val) redis.set(key, to_redis(val)) end def value from_redis redis.get(key) end alias_method :get, :value def delete redis.del(key) end alias_method :del, :delete def to_s; value.to_s; end alias_method :to_str, :to_s def ==(x); value == x; end def nil?; value.nil?; end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis-objects-0.2.1 | lib/redis/value.rb |