Module: Oxblood::Commands::Hashes

Included in:
Oxblood::Commands
Defined in:
lib/oxblood/commands/hashes.rb

Instance Method Summary collapse

Instance Method Details

#hdel(key, fields) ⇒ Integer

Removes the specified fields from the hash stored at key


13
14
15
# File 'lib/oxblood/commands/hashes.rb', line 13

def hdel(key, fields)
  run(:HDEL, key, fields)
end

#hexists(key, field) ⇒ Integer

Returns if field is an existing field in the hash stored at key


24
25
26
# File 'lib/oxblood/commands/hashes.rb', line 24

def hexists(key, field)
  run(:HEXISTS, key, field)
end

#hget(key, field) ⇒ String?

Get the value of a hash field


36
37
38
# File 'lib/oxblood/commands/hashes.rb', line 36

def hget(key, field)
  run(:HGET, key, field)
end

#hgetall(key) ⇒ Array

Get all the fields and values in a hash


47
48
49
# File 'lib/oxblood/commands/hashes.rb', line 47

def hgetall(key)
  run(:HGETALL, key)
end

#hincrby(key, field, increment) ⇒ Integer

Increment the integer value of a hash field by the given number


59
60
61
# File 'lib/oxblood/commands/hashes.rb', line 59

def hincrby(key, field, increment)
  run(:HINCRBY, key, field, increment)
end

#hincrbyfloat(key, field, increment) ⇒ String, RError

Increment the float value of a hash field by the given number


74
75
76
# File 'lib/oxblood/commands/hashes.rb', line 74

def hincrbyfloat(key, field, increment)
  run(:HINCRBYFLOAT, key, field, increment)
end

#hkeys(key) ⇒ Array

Get all the keys in a hash


85
86
87
# File 'lib/oxblood/commands/hashes.rb', line 85

def hkeys(key)
  run(:HKEYS, key)
end

#hlen(key) ⇒ Integer

Get the number of keys in a hash


96
97
98
# File 'lib/oxblood/commands/hashes.rb', line 96

def hlen(key)
  run(:HLEN, key)
end

#hmget(key, *fields) ⇒ Array

Get the field values of all given hash fields


108
109
110
# File 'lib/oxblood/commands/hashes.rb', line 108

def hmget(key, *fields)
  run(*fields.unshift(:HMGET, key))
end

#hmset(key, *args) ⇒ String

Set multiple hash fields to multiple values


119
120
121
# File 'lib/oxblood/commands/hashes.rb', line 119

def hmset(key, *args)
  run(*args.unshift(:HMSET, key))
end

#hscan(key, cursor, opts = {}) ⇒ Array

Incrementally iterate hash fields and associated values

Options Hash (opts):

  • :count (Integer)

    Amount of work that should be done at every call in order to retrieve elements from the collection.

  • :match (String)

See Also:


185
186
187
188
189
# File 'lib/oxblood/commands/hashes.rb', line 185

def hscan(key, cursor, opts = {})
  args = [:HSCAN, key, cursor]
  Scan.merge_opts!(args, opts)
  run(*args)
end

#hset(key, field, value) ⇒ Integer

Set the string value of a hash field


132
133
134
# File 'lib/oxblood/commands/hashes.rb', line 132

def hset(key, field, value)
  run(:HSET, key, field, value)
end

#hsetnx(key, field, value) ⇒ Integer

Set the value of a hash field, only if the field does not exist


145
146
147
# File 'lib/oxblood/commands/hashes.rb', line 145

def hsetnx(key, field, value)
  run(:HSETNX, key, field, value)
end

#hstrlen(key, field) ⇒ Integer

Get the length of the value of a hash field


157
158
159
# File 'lib/oxblood/commands/hashes.rb', line 157

def hstrlen(key, field)
  run(:HSTRLEN, key, field)
end

#hvals(key) ⇒ Array

Get all values in a hash


168
169
170
# File 'lib/oxblood/commands/hashes.rb', line 168

def hvals(key)
  run(:HVALS, key)
end