Module: Oxblood::Commands::Strings

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

Instance Method Summary collapse

Instance Method Details

#append(key, value) ⇒ Integer

Append a value to a key


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

def append(key, value)
  run(:APPEND, key, value)
end

#bitcount(key, *interval) ⇒ Integer

Count set bits in a string


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

def bitcount(key, *interval)
  run(*interval.unshift(:BITCOUNT, key))
end

#bitop(operation, destkey, *keys) ⇒ Integer

Perform bitwise operations between strings


35
36
37
# File 'lib/oxblood/commands/strings.rb', line 35

def bitop(operation, destkey, *keys)
  run(*keys.unshift(:BITOP, operation, destkey))
end

#bitpos(key, bit, *interval) ⇒ Integer

Find first bit set or clear in a string


48
49
50
# File 'lib/oxblood/commands/strings.rb', line 48

def bitpos(key, bit, *interval)
  run(*interval.unshift(:BITPOS, key, bit))
end

#decr(key) ⇒ Integer, RError

Decrement the integer value of a key by one


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

def decr(key)
  run(:DECR, key)
end

#decrby(key, decrement) ⇒ Integer, RError

Decrement the integer value of a key by the given number


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

def decrby(key, decrement)
  run(:DECRBY, key, decrement)
end

#get(key) ⇒ String?

Get the value of a key


82
83
84
# File 'lib/oxblood/commands/strings.rb', line 82

def get(key)
  run(:GET, key)
end

#getbit(key, offset) ⇒ Integer

Returns the bit value at offset in the string value stored at key


93
94
95
# File 'lib/oxblood/commands/strings.rb', line 93

def getbit(key, offset)
  run(:GETBIT, key, offset)
end

#getrange(key, start_pos, end_pos) ⇒ String

Get a substring of the string stored at a key


105
106
107
# File 'lib/oxblood/commands/strings.rb', line 105

def getrange(key, start_pos, end_pos)
  run(:GETRANGE, key, start_pos, end_pos)
end

#getset(key, value) ⇒ String?

Set the string value of a key and return its old value


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

def getset(key, value)
  run(:GETSET, key, value)
end

#incr(key) ⇒ Integer, RError

Increment the integer value of a key by one


129
130
131
# File 'lib/oxblood/commands/strings.rb', line 129

def incr(key)
  run(:INCR, key)
end

#incrby(key, increment) ⇒ Integer

Increment the integer value of a key by the given amount


140
141
142
# File 'lib/oxblood/commands/strings.rb', line 140

def incrby(key, increment)
  run(:INCRBY, key, increment)
end

#incrbyfloat(key, increment) ⇒ String

Increment the float value of a key by the given amount


151
152
153
# File 'lib/oxblood/commands/strings.rb', line 151

def incrbyfloat(key, increment)
  run(:INCRBYFLOAT, key, increment)
end

#mget(*keys) ⇒ Array

Get the values of all the given keys


161
162
163
# File 'lib/oxblood/commands/strings.rb', line 161

def mget(*keys)
  run(*keys.unshift(:MGET))
end

#mset(*keys_and_values) ⇒ String

Set multiple keys to multiple values


171
172
173
# File 'lib/oxblood/commands/strings.rb', line 171

def mset(*keys_and_values)
  run(*keys_and_values.unshift(:MSET))
end

#msetnx(*keys_and_values) ⇒ Integer

Set multiple keys to multiple values, only if none of the keys exist


182
183
184
# File 'lib/oxblood/commands/strings.rb', line 182

def msetnx(*keys_and_values)
  run(*keys_and_values.unshift(:MSETNX))
end

#psetex(key, milliseconds, value) ⇒ String

Set the value and expiration in milliseconds of a key


194
195
196
# File 'lib/oxblood/commands/strings.rb', line 194

def psetex(key, milliseconds, value)
  run(:PSETEX, key, milliseconds, value)
end

#set(key, value) ⇒ String

TODO:

Add support for set options redis.io/commands/set#options

Set the string value of a key


208
209
210
# File 'lib/oxblood/commands/strings.rb', line 208

def set(key, value)
  run(:SET, key, value)
end

#setbit(key, offset, value) ⇒ Integer

Set or clear the bit at offset in the string value stored at key


220
221
222
# File 'lib/oxblood/commands/strings.rb', line 220

def setbit(key, offset, value)
  run(:SETBIT, key, offset, value)
end

#setex(key, seconds, value) ⇒ String

Set the value and expiration of a key


232
233
234
# File 'lib/oxblood/commands/strings.rb', line 232

def setex(key, seconds, value)
  run(:SETEX, key, seconds, value)
end

#setnx(key, value) ⇒ Integer

Set the value of a key, only if the key does not exist


243
244
245
# File 'lib/oxblood/commands/strings.rb', line 243

def setnx(key, value)
  run(:SETNX, key, value)
end

#setrange(key, offset, value) ⇒ Integer

Overwrite part of a string at key starting at the specified offset


256
257
258
# File 'lib/oxblood/commands/strings.rb', line 256

def setrange(key, offset, value)
  run(:SETRANGE, key, offset, value)
end

#strlen(key) ⇒ Integer

Get the length of the value stored in a key


267
268
269
# File 'lib/oxblood/commands/strings.rb', line 267

def strlen(key)
  run(:STRLEN, key)
end