Module: Async::Redis::Methods::Strings
- Included in:
- Client, Context::Multi
- Defined in:
- lib/async/redis/methods/strings.rb
Instance Method Summary collapse
- #append(key, value) ⇒ Object
- #bitcount(key, *range) ⇒ Object
- #decr(key) ⇒ Object
- #decrby(key, decrement) ⇒ Object
- #get(key) ⇒ Object
- #getbit(key, offset) ⇒ Object
- #getrange(key, start_index, end_index) ⇒ Object
- #getset(key, value) ⇒ Object
- #incr(key) ⇒ Object
- #incrby(key, increment) ⇒ Object
- #incrbyfloat(key, increment) ⇒ Object
- #mget(key, *keys) ⇒ Object
- #mset(pairs) ⇒ Object
- #msetnx(pairs) ⇒ Object
- #psetex(key, milliseconds, value) ⇒ Object
- #set(key, value, **options) ⇒ Object
- #setbit(key, offset, value) ⇒ Object
- #setex(key, seconds, value) ⇒ Object
- #setnx(key, value) ⇒ Object
- #setrange(key, offset, value) ⇒ Object
- #strlen(key) ⇒ Object
Instance Method Details
#append(key, value) ⇒ Object
26 27 28 |
# File 'lib/async/redis/methods/strings.rb', line 26 def append(key, value) return call('APPEND', key, value) end |
#bitcount(key, *range) ⇒ Object
30 31 32 |
# File 'lib/async/redis/methods/strings.rb', line 30 def bitcount(key, *range) return call('BITCOUNT', key, *range) end |
#decr(key) ⇒ Object
34 35 36 |
# File 'lib/async/redis/methods/strings.rb', line 34 def decr(key) return call('DECR', key) end |
#decrby(key, decrement) ⇒ Object
38 39 40 |
# File 'lib/async/redis/methods/strings.rb', line 38 def decrby(key, decrement) return call('DECRBY', key, decrement) end |
#get(key) ⇒ Object
42 43 44 |
# File 'lib/async/redis/methods/strings.rb', line 42 def get(key) return call('GET', key) end |
#getbit(key, offset) ⇒ Object
46 47 48 |
# File 'lib/async/redis/methods/strings.rb', line 46 def getbit(key, offset) return call('GETBIT', key, offset) end |
#getrange(key, start_index, end_index) ⇒ Object
50 51 52 |
# File 'lib/async/redis/methods/strings.rb', line 50 def getrange(key, start_index, end_index) return call('GETRANGE', key, start_index, end_index) end |
#getset(key, value) ⇒ Object
54 55 56 |
# File 'lib/async/redis/methods/strings.rb', line 54 def getset(key, value) return call('GETSET', key, value) end |
#incr(key) ⇒ Object
58 59 60 |
# File 'lib/async/redis/methods/strings.rb', line 58 def incr(key) return call('INCR', key) end |
#incrby(key, increment) ⇒ Object
62 63 64 |
# File 'lib/async/redis/methods/strings.rb', line 62 def incrby(key, increment) return call('INCRBY', key, increment) end |
#incrbyfloat(key, increment) ⇒ Object
66 67 68 |
# File 'lib/async/redis/methods/strings.rb', line 66 def incrbyfloat(key, increment) return call('INCRBYFLOAT', key, increment) end |
#mget(key, *keys) ⇒ Object
70 71 72 |
# File 'lib/async/redis/methods/strings.rb', line 70 def mget(key, *keys) return call('MGET', key, *keys) end |
#mset(pairs) ⇒ Object
74 75 76 77 |
# File 'lib/async/redis/methods/strings.rb', line 74 def mset(pairs) flattened_pairs = pairs.keys.zip(pairs.values).flatten return call('MSET', *flattened_pairs) end |
#msetnx(pairs) ⇒ Object
79 80 81 82 |
# File 'lib/async/redis/methods/strings.rb', line 79 def msetnx(pairs) flattened_pairs = pairs.keys.zip(pairs.values).flatten return call('MSETNX', *flattened_pairs) end |
#psetex(key, milliseconds, value) ⇒ Object
84 85 86 |
# File 'lib/async/redis/methods/strings.rb', line 84 def psetex(key, milliseconds, value) return set key, value, milliseconds: milliseconds end |
#set(key, value, **options) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/async/redis/methods/strings.rb', line 88 def set(key, value, **) arguments = [] if .has_key? :seconds arguments << 'EX' arguments << [:seconds] end if .has_key? :milliseconds arguments << 'PX' arguments << [:milliseconds] end if [:condition] == :nx arguments << 'NX' elsif [:condition] == :xx arguments << 'XX' end return call('SET', key, value, *arguments) end |
#setbit(key, offset, value) ⇒ Object
110 111 112 |
# File 'lib/async/redis/methods/strings.rb', line 110 def setbit(key, offset, value) return call('SETBIT', key, offset, value) end |
#setex(key, seconds, value) ⇒ Object
114 115 116 |
# File 'lib/async/redis/methods/strings.rb', line 114 def setex(key, seconds, value) return set key, value, seconds: seconds end |
#setnx(key, value) ⇒ Object
118 119 120 |
# File 'lib/async/redis/methods/strings.rb', line 118 def setnx(key, value) return set key, value, condition: :nx end |
#setrange(key, offset, value) ⇒ Object
122 123 124 |
# File 'lib/async/redis/methods/strings.rb', line 122 def setrange(key, offset, value) return call('SETRANGE', key, offset, value) end |
#strlen(key) ⇒ Object
126 127 128 |
# File 'lib/async/redis/methods/strings.rb', line 126 def strlen(key) return call('STRLEN', key) end |