class Redis::Value

Class representing a simple value. You can use standard Ruby operations on it.

Public Instance Methods

==(other) click to toggle source
# File lib/redis/value.rb, line 58
def ==(other); value == other end
compress(value) click to toggle source
# File lib/redis/value.rb, line 50
def compress(value)
  Zlib::Deflate.deflate(value)
end
decompress(value) click to toggle source
# File lib/redis/value.rb, line 46
def decompress(value)
  Zlib::Inflate.inflate(value)
end
get()
Alias for: value
inspect() click to toggle source
# File lib/redis/value.rb, line 54
def inspect
  "#<Redis::Value #{value.inspect}>"
end
marshal(value, *args) click to toggle source
Calls superclass method Redis::Helpers::CoreCommands#marshal
# File lib/redis/value.rb, line 30
def marshal(value, *args)
  if !value.nil? && options[:compress]
    compress(super)
  else
    super
  end
end
method_missing(*args) click to toggle source
# File lib/redis/value.rb, line 61
def method_missing(*args)
  self.value.send *args
end
nil?() click to toggle source
# File lib/redis/value.rb, line 59
def nil?; value.nil? end
set(val)
Alias for: value=
unmarshal(value, *args) click to toggle source
Calls superclass method Redis::Helpers::CoreCommands#unmarshal
# File lib/redis/value.rb, line 38
def unmarshal(value, *args)
  if !value.nil? && options[:compress]
    super(decompress(value), *args)
  else
    super
  end
end
value() click to toggle source
# File lib/redis/value.rb, line 20
def value
  value = unmarshal(redis.get(key))
  if value.nil? && !@options[:default].nil?
    @options[:default]
  else
    value
  end
end
Also aliased as: get
value=(val) click to toggle source
# File lib/redis/value.rb, line 9
def value=(val)
  allow_expiration do
    if val.nil?
      delete
    else
      redis.set key, marshal(val)
    end
  end
end
Also aliased as: set