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



11
12
13
# File 'lib/oxblood/commands/hashes.rb', line 11

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



22
23
24
# File 'lib/oxblood/commands/hashes.rb', line 22

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

#hget(key, field) ⇒ String?

Get the value of a hash field



34
35
36
# File 'lib/oxblood/commands/hashes.rb', line 34

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

#hgetall(key) ⇒ Array

Get all the fields and values in a hash



45
46
47
# File 'lib/oxblood/commands/hashes.rb', line 45

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

#hincrby(key, field, increment) ⇒ Integer

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



57
58
59
# File 'lib/oxblood/commands/hashes.rb', line 57

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



72
73
74
# File 'lib/oxblood/commands/hashes.rb', line 72

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

#hkeys(key) ⇒ Array

Get all the keys in a hash



83
84
85
# File 'lib/oxblood/commands/hashes.rb', line 83

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

#hlen(key) ⇒ Integer

Get the number of keys in a hash



94
95
96
# File 'lib/oxblood/commands/hashes.rb', line 94

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

#hmget(key, *fields) ⇒ Array

Get the field values of all given hash fields



106
107
108
# File 'lib/oxblood/commands/hashes.rb', line 106

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

#hmset(key, *args) ⇒ String

Set multiple hash fields to multiple values



117
118
119
# File 'lib/oxblood/commands/hashes.rb', line 117

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

#hset(key, field, value) ⇒ Integer

Set the string value of a hash field



130
131
132
# File 'lib/oxblood/commands/hashes.rb', line 130

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



143
144
145
# File 'lib/oxblood/commands/hashes.rb', line 143

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



155
156
157
# File 'lib/oxblood/commands/hashes.rb', line 155

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

#hvals(key) ⇒ Array

Get all values in a hash



166
167
168
# File 'lib/oxblood/commands/hashes.rb', line 166

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