Module: Redis::Commands::Strings
- Included in:
- Redis::Commands
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb
Instance Method Summary collapse
-
#append(key, value) ⇒ Integer
Append a value to a key.
-
#decr(key) ⇒ Integer
Decrement the integer value of a key by one.
-
#decrby(key, decrement) ⇒ Integer
Decrement the integer value of a key by the given number.
-
#get(key) ⇒ String
Get the value of a key.
-
#getdel(key) ⇒ String
Get the value of key and delete the key.
-
#getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false) ⇒ String
Get the value of key and optionally set its expiration.
-
#getrange(key, start, stop) ⇒ Integer
Get a substring of the string stored at a key.
-
#getset(key, value) ⇒ String
Set the string value of a key and return its old value.
-
#incr(key) ⇒ Integer
Increment the integer value of a key by one.
-
#incrby(key, increment) ⇒ Integer
Increment the integer value of a key by the given integer number.
-
#incrbyfloat(key, increment) ⇒ Float
Increment the numeric value of a key by the given float number.
-
#mapped_mget(*keys) ⇒ Hash
Get the values of all the given keys.
-
#mapped_mset(hash) ⇒ String
Set one or more values.
-
#mapped_msetnx(hash) ⇒ Boolean
Set one or more values, only if none of the keys exist.
-
#mget(*keys, &blk) ⇒ Array<String>
Get the values of all the given keys.
-
#mset(*args) ⇒ String
Set one or more values.
-
#msetnx(*args) ⇒ Boolean
Set one or more values, only if none of the keys exist.
-
#psetex(key, ttl, value) ⇒ String
Set the time to live in milliseconds of a key.
-
#set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) ⇒ String, Boolean
Set the string value of a key.
-
#setex(key, ttl, value) ⇒ String
Set the time to live in seconds of a key.
-
#setnx(key, value) ⇒ Boolean
Set the value of a key, only if the key does not exist.
-
#setrange(key, offset, value) ⇒ Integer
Overwrite part of a string at key starting at the specified offset.
-
#strlen(key) ⇒ Integer
Get the length of the value stored in a key.
Instance Method Details
#append(key, value) ⇒ Integer
Append a value to a key.
255 256 257 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 255 def append(key, value) send_command([:append, key, value]) end |
#decr(key) ⇒ Integer
Decrement the integer value of a key by one.
14 15 16 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 14 def decr(key) send_command([:decr, key]) end |
#decrby(key, decrement) ⇒ Integer
Decrement the integer value of a key by the given number.
27 28 29 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 27 def decrby(key, decrement) send_command([:decrby, key, Integer(decrement)]) end |
#get(key) ⇒ String
Get the value of a key.
190 191 192 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 190 def get(key) send_command([:get, key]) end |
#getdel(key) ⇒ String
Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success.
275 276 277 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 275 def getdel(key) send_command([:getdel, key]) end |
#getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false) ⇒ String
Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options. When no options are provided, GETEX behaves like GET.
293 294 295 296 297 298 299 300 301 302 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 293 def getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false) args = [:getex, key] args << "EX" << Integer(ex) if ex args << "PX" << Integer(px) if px args << "EXAT" << Integer(exat) if exat args << "PXAT" << Integer(pxat) if pxat args << "PERSIST" if persist send_command(args) end |
#getrange(key, start, stop) ⇒ Integer
Get a substring of the string stored at a key.
246 247 248 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 246 def getrange(key, start, stop) send_command([:getrange, key, Integer(start), Integer(stop)]) end |
#getset(key, value) ⇒ String
Set the string value of a key and return its old value.
265 266 267 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 265 def getset(key, value) send_command([:getset, key, value.to_s]) end |
#incr(key) ⇒ Integer
Increment the integer value of a key by one.
39 40 41 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 39 def incr(key) send_command([:incr, key]) end |
#incrby(key, increment) ⇒ Integer
Increment the integer value of a key by the given integer number.
52 53 54 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 52 def incrby(key, increment) send_command([:incrby, key, Integer(increment)]) end |
#incrbyfloat(key, increment) ⇒ Float
Increment the numeric value of a key by the given float number.
65 66 67 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 65 def incrbyfloat(key, increment) send_command([:incrbyfloat, key, Float(increment)], &Floatify) end |
#mapped_mget(*keys) ⇒ Hash
Get the values of all the given keys.
219 220 221 222 223 224 225 226 227 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 219 def mapped_mget(*keys) mget(*keys) do |reply| if reply.is_a?(Array) Hash[keys.zip(reply)] else reply end end end |
#mapped_mset(hash) ⇒ String
Set one or more values.
154 155 156 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 154 def mapped_mset(hash) mset(hash.flatten) end |
#mapped_msetnx(hash) ⇒ Boolean
Set one or more values, only if none of the keys exist.
182 183 184 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 182 def mapped_msetnx(hash) msetnx(hash.flatten) end |
#mget(*keys, &blk) ⇒ Array<String>
Get the values of all the given keys.
204 205 206 207 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 204 def mget(*keys, &blk) keys.flatten!(1) send_command([:mget, *keys], &blk) end |
#mset(*args) ⇒ String
Set one or more values.
140 141 142 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 140 def mset(*args) send_command([:mset] + args) end |
#msetnx(*args) ⇒ Boolean
Set one or more values, only if none of the keys exist.
168 169 170 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 168 def msetnx(*args) send_command([:msetnx, *args], &Boolify) end |
#psetex(key, ttl, value) ⇒ String
Set the time to live in milliseconds of a key.
117 118 119 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 117 def psetex(key, ttl, value) send_command([:psetex, key, Integer(ttl), value.to_s]) end |
#set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) ⇒ String, Boolean
Set the string value of a key.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 83 def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) args = [:set, key, value.to_s] args << "EX" << Integer(ex) if ex args << "PX" << Integer(px) if px args << "EXAT" << Integer(exat) if exat args << "PXAT" << Integer(pxat) if pxat args << "NX" if nx args << "XX" if xx args << "KEEPTTL" if keepttl args << "GET" if get if nx || xx send_command(args, &BoolifySet) else send_command(args) end end |
#setex(key, ttl, value) ⇒ String
Set the time to live in seconds of a key.
107 108 109 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 107 def setex(key, ttl, value) send_command([:setex, key, Integer(ttl), value.to_s]) end |
#setnx(key, value) ⇒ Boolean
Set the value of a key, only if the key does not exist.
126 127 128 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 126 def setnx(key, value) send_command([:setnx, key, value.to_s], &Boolify) end |
#setrange(key, offset, value) ⇒ Integer
Overwrite part of a string at key starting at the specified offset.
235 236 237 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 235 def setrange(key, offset, value) send_command([:setrange, key, Integer(offset), value.to_s]) end |
#strlen(key) ⇒ Integer
Get the length of the value stored in a key.
309 310 311 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/strings.rb', line 309 def strlen(key) send_command([:strlen, key]) end |