Module: RedisCluster::Function::Hash
- Included in:
- RedisCluster::Function
- Defined in:
- lib/redis_cluster/function/hash.rb
Overview
Hash implement redis hashes commands. There will be some adjustment for cluster. see redis.io/commands#hash. Most of the code are copied from github.com/redis/redis-rb/blob/master/lib/redis.rb.
SETTER = [:hdel, :hincrby, :hincrbyfloat, :hmset, :hset, :hsetnx] GETTER = [:hexists, :hget, :hgetall, :hkeys, :hlen, :hmget, :hstrlen, :hvals, :hscan]
Instance Method Summary collapse
-
#hdel(key, field) ⇒ Fixnum
Delete one or more hash fields.
-
#hexists(key, field) ⇒ Boolean
Determine if a hash field exists.
-
#hget(key, field) ⇒ String
Get the value of a hash field.
-
#hgetall(key) ⇒ Hash<String, String>
Get all the fields and values in a hash.
-
#hincrby(key, field, increment) ⇒ Fixnum
Increment the integer value of a hash field by the given integer number.
-
#hincrbyfloat(key, field, increment) ⇒ Float
Increment the numeric value of a hash field by the given float number.
-
#hkeys(key) ⇒ Array<String>
Get all the fields in a hash.
-
#hlen(key) ⇒ Fixnum
Get the number of fields in a hash.
-
#hmget(key, *fields) ⇒ Array<String>
Get the values of all the given hash fields.
-
#hmset(key, *attrs) ⇒ String
Set one or more hash values.
-
#hset(key, field, value) ⇒ Boolean
Set the string value of a hash field.
-
#hsetnx(key, field, value) ⇒ Boolean
Set the value of a hash field, only if the field does not exist.
-
#hstrlen(key, field) ⇒ Fixnum
Returns the string length of the value associated with field in the hash stored at key.
-
#hvals(key) ⇒ Array<String>
Get all the values in a hash.
Instance Method Details
#hdel(key, field) ⇒ Fixnum
Delete one or more hash fields.
21 22 23 |
# File 'lib/redis_cluster/function/hash.rb', line 21 def hdel(key, field) call(key, [:hdel, key, field]) end |
#hexists(key, field) ⇒ Boolean
Determine if a hash field exists.
83 84 85 |
# File 'lib/redis_cluster/function/hash.rb', line 83 def hexists(key, field) call(key, [:hexists, key, field], transform: Redis::Boolify, read: true) end |
#hget(key, field) ⇒ String
Get the value of a hash field.
92 93 94 |
# File 'lib/redis_cluster/function/hash.rb', line 92 def hget(key, field) call(key, [:hget, key, field], read: true) end |
#hgetall(key) ⇒ Hash<String, String>
Get all the fields and values in a hash.
100 101 102 |
# File 'lib/redis_cluster/function/hash.rb', line 100 def hgetall(key) call(key, [:hgetall, key], transform: Redis::Hashify, read: true) end |
#hincrby(key, field, increment) ⇒ Fixnum
Increment the integer value of a hash field by the given integer number.
31 32 33 |
# File 'lib/redis_cluster/function/hash.rb', line 31 def hincrby(key, field, increment) call(key, [:hincrby, key, field, increment]) end |
#hincrbyfloat(key, field, increment) ⇒ Float
Increment the numeric value of a hash field by the given float number.
41 42 43 |
# File 'lib/redis_cluster/function/hash.rb', line 41 def hincrbyfloat(key, field, increment) call(key, [:hincrbyfloat, key, field, increment], transform: Redis::Floatify) end |
#hkeys(key) ⇒ Array<String>
Get all the fields in a hash.
108 109 110 |
# File 'lib/redis_cluster/function/hash.rb', line 108 def hkeys(key) call(key, [:hkeys, key], read: true) end |
#hlen(key) ⇒ Fixnum
Get the number of fields in a hash.
124 125 126 |
# File 'lib/redis_cluster/function/hash.rb', line 124 def hlen(key) call(key, [:hlen, key], read: true) end |
#hmget(key, *fields) ⇒ Array<String>
Get the values of all the given hash fields.
137 138 139 |
# File 'lib/redis_cluster/function/hash.rb', line 137 def hmget(key, *fields) call(key, [:hmget, key] + fields, read: true) end |
#hmset(key, *attrs) ⇒ String
Set one or more hash values.
54 55 56 |
# File 'lib/redis_cluster/function/hash.rb', line 54 def hmset(key, *attrs) call(key, [:hmset, key] + attrs) end |
#hset(key, field, value) ⇒ Boolean
Set the string value of a hash field.
64 65 66 |
# File 'lib/redis_cluster/function/hash.rb', line 64 def hset(key, field, value) call(key, [:hset, key, field, value], transform: Redis::Boolify) end |
#hsetnx(key, field, value) ⇒ Boolean
Set the value of a hash field, only if the field does not exist.
74 75 76 |
# File 'lib/redis_cluster/function/hash.rb', line 74 def hsetnx(key, field, value) call(key, [:hsetnx, key, field, value], transform: Redis::Boolify) end |
#hstrlen(key, field) ⇒ Fixnum
Returns the string length of the value associated with field in the hash stored at key.
146 147 148 |
# File 'lib/redis_cluster/function/hash.rb', line 146 def hstrlen(key, field) call(key, [:hstrlen, key, field], read: true) end |
#hvals(key) ⇒ Array<String>
Get all the values in a hash.
116 117 118 |
# File 'lib/redis_cluster/function/hash.rb', line 116 def hvals(key) call(key, [:hvals, key], read: true) end |