module Redis::Store::Namespace

Public Instance Methods

decrby(key, increment) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 24
def decrby(key, increment)
  namespace(key) { |key| super(key, increment) }
end
del(*keys) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 32
def del(*keys)
  super *keys.map {|key| interpolate(key) } if keys.any?
end
exists(key) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 16
def exists(key)
  namespace(key) { |key| super(key) }
end
flushdb() click to toggle source
# File lib/redis/store/namespace.rb, line 44
def flushdb
  del *keys
end
get(key, options = nil) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 12
def get(key, options = nil)
  namespace(key) { |key| super(key, options) }
end
incrby(key, increment) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 20
def incrby(key, increment)
  namespace(key) { |key| super(key, increment) }
end
keys(pattern = "*") click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 28
def keys(pattern = "*")
  namespace(pattern) { |pattern| super(pattern).map{|key| strip_namespace(key) } }
end
mget(*keys) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 36
def mget(*keys)
  super *keys.map {|key| interpolate(key) } if keys.any?
end
set(key, val, options = nil) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 4
def set(key, val, options = nil)
  namespace(key) { |key| super(key, val, options) }
end
setnx(key, val, options = nil) click to toggle source
Calls superclass method
# File lib/redis/store/namespace.rb, line 8
def setnx(key, val, options = nil)
  namespace(key) { |key| super(key, val, options) }
end
to_s() click to toggle source
# File lib/redis/store/namespace.rb, line 40
def to_s
  "#{super} with namespace #{@namespace}"
end

Private Instance Methods

interpolate(key) click to toggle source
# File lib/redis/store/namespace.rb, line 53
def interpolate(key)
  key.match(namespace_regexp) ? key : "#{@namespace}:#{key}"
end
namespace(key) { |interpolate(key)| ... } click to toggle source
# File lib/redis/store/namespace.rb, line 49
def namespace(key)
  yield interpolate(key)
end
namespace_regexp() click to toggle source
# File lib/redis/store/namespace.rb, line 61
def namespace_regexp
  @namespace_regexp ||= %r{^#{@namespace}\:}
end
strip_namespace(key) click to toggle source
# File lib/redis/store/namespace.rb, line 57
def strip_namespace(key)
  key.gsub namespace_regexp, ""
end