vendor/bundle/ruby/1.8/gems/redis-namespace-1.0.3/lib/redis/namespace.rb
# The following table defines how input parameters and result
# values should be modified for the namespace.
#
# COMMANDS is a hash. Each key is the name of a command and each
# value is a two element array.
#
# The first element in the value array describes how to modify the
# arguments passed. It can be one of:
#
#   nil
#     Do nothing.
#   :first
#     Add the namespace to the first argument passed, e.g.
#       GET key => GET namespace:key
#   :all
#     Add the namespace to all arguments passed, e.g.
#       MGET key1 key2 => MGET namespace:key1 namespace:key2
#   :exclude_first
#     Add the namespace to all arguments but the first, e.g.
#   :exclude_last
#     Add the namespace to all arguments but the last, e.g.
#       BLPOP key1 key2 timeout =>
#       BLPOP namespace:key1 namespace:key2 timeout
#   :alternate
#     Add the namespace to every other argument, e.g.
#       MSET key1 value1 key2 value2 =>
#       MSET namespace:key1 value1 namespace:key2 value2
#
# The second element in the value array describes how to modify
# the return value of the Redis call. It can be one of:
#
#   nil
#     Do nothing.
#   :all
#     Add the namespace to all elements returned, e.g.
#       key1 key2 => namespace:key1 namespace:key2
The following table defines how input parameters and result
values should be modified for the namespace.

COMMANDS is a hash. Each key is the name of a command and each
value is a two element array.

The first element in the value array describes how to modify the
arguments passed. It can be one of.

nil
Do nothing.
:first
Add the namespace to the first argument passed, e.g.
GET key => GET namespace:key
:all
Add the namespace to all arguments passed, e.g.
MGET key1 key2 => MGET namespace:key1 namespace:key2
:exclude_first
Add the namespace to all arguments but the first, e.g.
:exclude_last
Add the namespace to all arguments but the last, e.g.
BLPOP key1 key2 timeout =>
BLPOP namespace:key1 namespace:key2 timeout
:alternate
Add the namespace to every other argument, e.g.
MSET key1 value1 key2 value2 =>
MSET namespace:key1 value1 namespace:key2 value2

The second element in the value array describes how to modify
the return value of the Redis call. It can be one of.

nil
Do nothing.
:all
Add the namespace to all elements returned, e.g.
key1 key2 => namespace:key1 namespace:key2
The following table defines how input parameters and result values should be modified for the namespace . COMMANDS is a hash . Each key is the name of a command and each value is a two element array . The first element in the value array describes how to modify the arguments passed . It can be one of . nil Do nothing . : first Add the namespace to the first argument passed e . g . GET key = > GET namespace : key : all Add the namespace to all arguments passed e . g . MGET key1 key2 = > MGET namespace : key1 namespace : key2 : exclude_first Add the namespace to all arguments but the first e . g . : exclude_last Add the namespace to all arguments but the last e . g . BLPOP key1 key2 timeout = > BLPOP namespace : key1 namespace : key2 timeout : alternate Add the namespace to every other argument e . g . MSET key1 value1 key2 value2 = > MSET namespace : key1 value1 namespace : key2 value2 The second element in the value array describes how to modify the return value of the Redis call . It can be one of . nil Do nothing . : all Add the namespace to all elements returned e . g . key1 key2 = > namespace : key1 namespace : key2
def rem_namespace(key)
      return key unless key && @namespace
      case key
      when Array
        key.map {|k| rem_namespace k}
      when Hash
        Hash[*key.map {|k, v| [ rem_namespace(k), v ]}.flatten]
      else
        key.to_s.gsub /^#{@namespace}:/, ""
      end
    end
def rem_namespace ( key ) return key unless key && @namespace case key when Array key . map { | k | rem_namespace k } when Hash Hash [ * key . map { | k , v | [ rem_namespace ( k ) , v ] } . flatten ] else key . to_s . gsub / ^ #{ @namespace } : / , "" end end
The following table defines how input parameters and result
values should be modified for the namespace.
The following table defines how input parameters and result values should be modified for the namespace .
key