class Bindi

Constants

VERSION

Public Class Methods

new(serializer = Marshal) click to toggle source
# File lib/bindi.rb, line 4
def initialize serializer = Marshal
  @serializer = serializer
  @redis = Redis.new
end

Public Instance Methods

[](key) click to toggle source
# File lib/bindi.rb, line 9
def [] key
  @serializer.load(@redis.get key) if @redis.exists key
end
[]=(key, value) click to toggle source
# File lib/bindi.rb, line 13
def []= key, value
  @redis.set key, @serializer.dump(value)
end
clear() click to toggle source
# File lib/bindi.rb, line 17
def clear
  [] if @redis.flushdb == "OK"
end
delete(key) click to toggle source
# File lib/bindi.rb, line 21
def delete key
  if key? key
    value = @serializer.load(@redis.get key)
    @redis.del key
    value
  end
end
empty?() click to toggle source
# File lib/bindi.rb, line 29
def empty?
  @redis.keys.empty?
end
has_key(key)
Alias for: key?
info() click to toggle source
# File lib/bindi.rb, line 33
def info
  @redis.info
end
inspect() click to toggle source
# File lib/bindi.rb, line 37
def inspect
  @redis.inspect
end
Also aliased as: to_s
key?(key) click to toggle source
# File lib/bindi.rb, line 42
def key? key
  @redis.exists key
end
Also aliased as: has_key
keys() click to toggle source
# File lib/bindi.rb, line 47
def keys
  @redis.keys
end
to_s()
Alias for: inspect