protocol-redis 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9a0af74e1d169a5d9f8b712a1211deb9c2ab510c969043073e685b5a4d4a99a
4
- data.tar.gz: 7961d5412651f7969160e5b3844be5ab7db064b5b1f2ff6833ca17e12cc42233
3
+ metadata.gz: e43c648ff264ee29a69f92fc31f9c82435adccc55e47030268d2f82c74334974
4
+ data.tar.gz: afec0aedb9963f4a48d2f4f2c9ba63079b376f8bb120bf7d78cb6e993d94c267
5
5
  SHA512:
6
- metadata.gz: 6fdf6ab96249d724ea77949cd073cb581f8ad58b96e3d54058e5f2e466ae2de7a947f327b44367a38d65939c2b8d8ed7a72f3e24a408f15871d25c35e45f271a
7
- data.tar.gz: 27ca946edfed62633623d6876a04cdd36da92b95fbf0e21d5086b493580b1988d4d1a68e9f3ff1f99c1e9da4bc71b812688941b10d799c6dd6060a107c24427a
6
+ metadata.gz: 2356a25989896ad34bfa432627e9967cd1695898df66107e975ede10e70c8bd5f3a2cbac4c1a136fcff317306823917800106c02b6b719c4d2352176b9182234
7
+ data.tar.gz: 5616240fd409f903c2f52e99e5ee3c8e0792b81bc933dcfab1366c56bf9ce1dfed0cdc9780f0440aae079205f25b6274eab235635573d1ff78b9cb24ce340c1d
@@ -32,7 +32,7 @@ module Protocol
32
32
  # @param key [Key]
33
33
  def del(*keys)
34
34
  if keys.any?
35
- return call('DEL', *keys)
35
+ call('DEL', *keys)
36
36
  end
37
37
  end
38
38
 
@@ -40,14 +40,14 @@ module Protocol
40
40
  # @see https://redis.io/commands/dump
41
41
  # @param key [Key]
42
42
  def dump(key)
43
- return call('DUMP', key)
43
+ call('DUMP', key)
44
44
  end
45
45
 
46
46
  # Determine if a key exists. O(1).
47
47
  # @see https://redis.io/commands/exists
48
48
  # @param key [Key]
49
49
  def exists(key, *keys)
50
- return call('EXISTS', key, *keys)
50
+ call('EXISTS', key, *keys)
51
51
  end
52
52
 
53
53
  # Set a key's time to live in seconds. O(1).
@@ -55,7 +55,7 @@ module Protocol
55
55
  # @param key [Key]
56
56
  # @param seconds [Integer]
57
57
  def expire(key, seconds)
58
- return call('EXPIRE', key, seconds)
58
+ call('EXPIRE', key, seconds)
59
59
  end
60
60
 
61
61
  # Set the expiration for a key as a UNIX timestamp. O(1).
@@ -70,14 +70,14 @@ module Protocol
70
70
  timestamp = time
71
71
  end
72
72
 
73
- return call('EXPIREAT', key, timestamp)
73
+ call('EXPIREAT', key, timestamp)
74
74
  end
75
75
 
76
76
  # Find all keys matching the given pattern. O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.
77
77
  # @see https://redis.io/commands/keys
78
78
  # @param pattern [Pattern]
79
79
  def keys(pattern)
80
- return call('KEYS', pattern)
80
+ call('KEYS', pattern)
81
81
  end
82
82
 
83
83
  # Atomically transfer a key from a Redis instance to another one. This command actually executes a DUMP+DEL in the source instance, and a RESTORE in the target instance. See the pages of these commands for time complexity. Also an O(N) data transfer between the two instances is performed.
@@ -118,7 +118,7 @@ module Protocol
118
118
  arguments.append("KEYS", *keys)
119
119
  end
120
120
 
121
- return call("MIGRATE", *arguments)
121
+ call("MIGRATE", *arguments)
122
122
  end
123
123
 
124
124
  # Move a key to another database. O(1).
@@ -126,7 +126,7 @@ module Protocol
126
126
  # @param key [Key]
127
127
  # @param db [Integer]
128
128
  def move(key, db)
129
- return call('MOVE', key, db)
129
+ call('MOVE', key, db)
130
130
  end
131
131
 
132
132
  # Inspect the internals of Redis objects. O(1) for all the currently implemented subcommands.
@@ -141,7 +141,7 @@ module Protocol
141
141
  # @see https://redis.io/commands/persist
142
142
  # @param key [Key]
143
143
  def persist(key)
144
- return call('PERSIST', key)
144
+ call('PERSIST', key)
145
145
  end
146
146
 
147
147
  # Set a key's time to live in milliseconds. O(1).
@@ -149,7 +149,7 @@ module Protocol
149
149
  # @param key [Key]
150
150
  # @param milliseconds [Integer]
151
151
  def pexpire(key, milliseconds)
152
- return call('PEXPIRE', milliseconds)
152
+ call('PEXPIRE', milliseconds)
153
153
  end
154
154
 
155
155
  # Set the expiration for a key as a UNIX timestamp specified in milliseconds. O(1).
@@ -164,20 +164,20 @@ module Protocol
164
164
  timestamp = time
165
165
  end
166
166
 
167
- return call('PEXPIREAT', key, timestamp)
167
+ call('PEXPIREAT', key, timestamp)
168
168
  end
169
169
 
170
170
  # Get the time to live for a key in milliseconds. O(1).
171
171
  # @see https://redis.io/commands/pttl
172
172
  # @param key [Key]
173
173
  def pttl(key)
174
- return call('PTTL', key)
174
+ call('PTTL', key)
175
175
  end
176
176
 
177
177
  # Return a random key from the keyspace. O(1).
178
178
  # @see https://redis.io/commands/randomkey
179
179
  def randomkey
180
- return call('RANDOMKEY')
180
+ call('RANDOMKEY')
181
181
  end
182
182
 
183
183
  # Rename a key. O(1).
@@ -185,7 +185,7 @@ module Protocol
185
185
  # @param key [Key]
186
186
  # @param newkey [Key]
187
187
  def rename(key, new_key)
188
- return call('RENAME', key, new_key)
188
+ call('RENAME', key, new_key)
189
189
  end
190
190
 
191
191
  # Rename a key, only if the new key does not exist. O(1).
@@ -193,7 +193,7 @@ module Protocol
193
193
  # @param key [Key]
194
194
  # @param newkey [Key]
195
195
  def renamenx(key, new_key)
196
- return call('RENAMENX', key, new_key)
196
+ call('RENAMENX', key, new_key)
197
197
  end
198
198
 
199
199
  # Create a key using the provided serialized value, previously obtained using DUMP. O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).
@@ -204,7 +204,7 @@ module Protocol
204
204
  # @param replace [Enum]
205
205
  # @param absttl [Enum]
206
206
  def restore(key, serialized_value, ttl=0)
207
- return call('RESTORE', key, ttl, serialized_value)
207
+ call('RESTORE', key, ttl, serialized_value)
208
208
  end
209
209
 
210
210
  # Incrementally iterate the keys space. O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.
@@ -225,7 +225,7 @@ module Protocol
225
225
  arguments.append("TYPE", type)
226
226
  end
227
227
 
228
- return call("SCAN", *arguments)
228
+ call("SCAN", *arguments)
229
229
  end
230
230
 
231
231
  # Sort the elements in a list, set or sorted set. O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is currently O(N) as there is a copy step that will be avoided in next releases.
@@ -260,35 +260,35 @@ module Protocol
260
260
  arguments.append("STORE", store)
261
261
  end
262
262
 
263
- return call('SORT', *arguments)
263
+ call('SORT', *arguments)
264
264
  end
265
265
 
266
266
  # Alters the last access time of a key(s). Returns the number of existing keys specified. O(N) where N is the number of keys that will be touched.
267
267
  # @see https://redis.io/commands/touch
268
268
  # @param key [Key]
269
269
  def touch(key, *keys)
270
- return call('TOUCH', key, *keys)
270
+ call('TOUCH', key, *keys)
271
271
  end
272
272
 
273
273
  # Get the time to live for a key. O(1).
274
274
  # @see https://redis.io/commands/ttl
275
275
  # @param key [Key]
276
276
  def ttl(key)
277
- return call('TTL', key)
277
+ call('TTL', key)
278
278
  end
279
279
 
280
280
  # Determine the type stored at key. O(1).
281
281
  # @see https://redis.io/commands/type
282
282
  # @param key [Key]
283
283
  def type(key)
284
- return call('TYPE', key)
284
+ call('TYPE', key)
285
285
  end
286
286
 
287
287
  # Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking. O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.
288
288
  # @see https://redis.io/commands/unlink
289
289
  # @param key [Key]
290
290
  def unlink(key)
291
- return call('UNLINK', key)
291
+ call('UNLINK', key)
292
292
  end
293
293
 
294
294
  # Wait for the synchronous replication of all the write commands sent in the context of the current connection. O(1).
@@ -296,7 +296,7 @@ module Protocol
296
296
  # @param numreplicas [Integer]
297
297
  # @param timeout [Integer]
298
298
  def wait(newreplicas, timeout = 0)
299
- return call("WAIT", numreplicas, timeout)
299
+ call("WAIT", numreplicas, timeout)
300
300
  end
301
301
  end
302
302
  end
@@ -28,14 +28,14 @@ module Protocol
28
28
  # @see https://redis.io/commands/hlen
29
29
  # @param key [Key]
30
30
  def hlen(key)
31
- return call('HLEN', key)
31
+ call('HLEN', key)
32
32
  end
33
33
 
34
34
  # Set the string value of a hash field. O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.
35
35
  # @see https://redis.io/commands/hset
36
36
  # @param key [Key]
37
37
  def hset(key, field, value)
38
- return call('HSET', key, field, value)
38
+ call('HSET', key, field, value)
39
39
  end
40
40
 
41
41
  # Set the value of a hash field, only if the field does not exist. O(1).
@@ -44,14 +44,14 @@ module Protocol
44
44
  # @param field [String]
45
45
  # @param value [String]
46
46
  def hsetnx(key, field, value)
47
- return call('HSETNX', key, field, value)
47
+ call('HSETNX', key, field, value)
48
48
  end
49
49
 
50
50
  # Set multiple hash fields to multiple values. O(N) where N is the number of fields being set.
51
51
  # @see https://redis.io/commands/hmset
52
52
  # @param key [Key]
53
53
  def hmset(key, *attrs)
54
- return call('HMSET', key, *attrs)
54
+ call('HMSET', key, *attrs)
55
55
  end
56
56
 
57
57
  # Get the value of a hash field. O(1).
@@ -59,7 +59,7 @@ module Protocol
59
59
  # @param key [Key]
60
60
  # @param field [String]
61
61
  def hget(key, field)
62
- return call('HGET', key, field)
62
+ call('HGET', key, field)
63
63
  end
64
64
 
65
65
  # Get the values of all the given hash fields. O(N) where N is the number of fields being requested.
@@ -67,7 +67,7 @@ module Protocol
67
67
  # @param key [Key]
68
68
  # @param field [String]
69
69
  def hmget(key, *fields, &blk)
70
- return call('HMGET', key, *fields, &blk)
70
+ call('HMGET', key, *fields, &blk)
71
71
  end
72
72
 
73
73
  # Delete one or more hash fields. O(N) where N is the number of fields to be removed.
@@ -75,7 +75,7 @@ module Protocol
75
75
  # @param key [Key]
76
76
  # @param field [String]
77
77
  def hdel(key, *fields)
78
- return call('HDEL', key, *fields)
78
+ call('HDEL', key, *fields)
79
79
  end
80
80
 
81
81
  # Determine if a hash field exists. O(1).
@@ -83,7 +83,7 @@ module Protocol
83
83
  # @param key [Key]
84
84
  # @param field [String]
85
85
  def hexists(key, field)
86
- return call('HEXISTS', key, field)
86
+ call('HEXISTS', key, field)
87
87
  end
88
88
 
89
89
  # Increment the integer value of a hash field by the given number. O(1).
@@ -92,7 +92,7 @@ module Protocol
92
92
  # @param field [String]
93
93
  # @param increment [Integer]
94
94
  def hincrby(key, field, increment)
95
- return call('HINCRBY', key, field, increment)
95
+ call('HINCRBY', key, field, increment)
96
96
  end
97
97
 
98
98
  # Increment the float value of a hash field by the given amount. O(1).
@@ -101,28 +101,28 @@ module Protocol
101
101
  # @param field [String]
102
102
  # @param increment [Double]
103
103
  def hincrbyfloat(key, field, increment)
104
- return call('HINCRBYFLOAT', key, field, increment)
104
+ call('HINCRBYFLOAT', key, field, increment)
105
105
  end
106
106
 
107
107
  # Get all the fields in a hash. O(N) where N is the size of the hash.
108
108
  # @see https://redis.io/commands/hkeys
109
109
  # @param key [Key]
110
110
  def hkeys(key)
111
- return call('HKEYS', key)
111
+ call('HKEYS', key)
112
112
  end
113
113
 
114
114
  # Get all the values in a hash. O(N) where N is the size of the hash.
115
115
  # @see https://redis.io/commands/hvals
116
116
  # @param key [Key]
117
117
  def hvals(key)
118
- return call('HVALS', key)
118
+ call('HVALS', key)
119
119
  end
120
120
 
121
121
  # Get all the fields and values in a hash. O(N) where N is the size of the hash.
122
122
  # @see https://redis.io/commands/hgetall
123
123
  # @param key [Key]
124
124
  def hgetall(key)
125
- return call('HGETALL', key)
125
+ call('HGETALL', key)
126
126
  end
127
127
  end
128
128
  end
@@ -30,7 +30,7 @@ module Protocol
30
30
  # @param key [Key]
31
31
  # @param timeout [Integer]
32
32
  def blpop(*keys, timeout: 0)
33
- return call('BLPOP', *keys, timeout)
33
+ call('BLPOP', *keys, timeout)
34
34
  end
35
35
 
36
36
  # Remove and get the last element in a list, or block until one is available. O(1).
@@ -38,7 +38,7 @@ module Protocol
38
38
  # @param key [Key]
39
39
  # @param timeout [Integer]
40
40
  def brpop(*keys, timeout: 0)
41
- return call('BRPOP', *keys, timeout)
41
+ call('BRPOP', *keys, timeout)
42
42
  end
43
43
 
44
44
  # Pop an element from a list, push it to another list and return it; or block until one is available. O(1).
@@ -47,7 +47,7 @@ module Protocol
47
47
  # @param destination [Key]
48
48
  # @param timeout [Integer]
49
49
  def brpoplpush(source, destination, timeout)
50
- return call('BRPOPLPUSH', source, destination, timeout)
50
+ call('BRPOPLPUSH', source, destination, timeout)
51
51
  end
52
52
 
53
53
  # Get an element from a list by its index. O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1).
@@ -55,7 +55,7 @@ module Protocol
55
55
  # @param key [Key]
56
56
  # @param index [Integer]
57
57
  def lindex(key, index)
58
- return call('LINDEX', key, index)
58
+ call('LINDEX', key, index)
59
59
  end
60
60
 
61
61
  # Insert an element before or after another element in a list. O(N) where N is the number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).
@@ -71,21 +71,21 @@ module Protocol
71
71
  offset = 'AFTER'
72
72
  end
73
73
 
74
- return call('LINSERT', key, offset, index, value)
74
+ call('LINSERT', key, offset, index, value)
75
75
  end
76
76
 
77
77
  # Get the length of a list. O(1).
78
78
  # @see https://redis.io/commands/llen
79
79
  # @param key [Key]
80
80
  def llen(key)
81
- return call('LLEN', key)
81
+ call('LLEN', key)
82
82
  end
83
83
 
84
84
  # Remove and get the first element in a list. O(1).
85
85
  # @see https://redis.io/commands/lpop
86
86
  # @param key [Key]
87
87
  def lpop(key)
88
- return call('LPOP', key)
88
+ call('LPOP', key)
89
89
  end
90
90
 
91
91
  # Prepend one or multiple elements to a list. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
@@ -100,7 +100,7 @@ module Protocol
100
100
  values = [value] + values
101
101
  end
102
102
 
103
- return call('LPUSH', key, *values)
103
+ call('LPUSH', key, *values)
104
104
  end
105
105
 
106
106
  # Prepend an element to a list, only if the list exists. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
@@ -108,7 +108,7 @@ module Protocol
108
108
  # @param key [Key]
109
109
  # @param element [String]
110
110
  def lpushx(key, value)
111
- return call('LPUSHX', key, value)
111
+ call('LPUSHX', key, value)
112
112
  end
113
113
 
114
114
  # Get a range of elements from a list. O(S+N) where S is the distance of start offset from HEAD for small lists, from nearest end (HEAD or TAIL) for large lists; and N is the number of elements in the specified range.
@@ -117,7 +117,7 @@ module Protocol
117
117
  # @param start [Integer]
118
118
  # @param stop [Integer]
119
119
  def lrange(key, start, stop)
120
- return call('LRANGE', key, start, stop)
120
+ call('LRANGE', key, start, stop)
121
121
  end
122
122
 
123
123
  # Remove elements from a list. O(N+M) where N is the length of the list and M is the number of elements removed.
@@ -126,7 +126,7 @@ module Protocol
126
126
  # @param count [Integer]
127
127
  # @param element [String]
128
128
  def lrem(key, count, value)
129
- return call('LREM', key, count, value)
129
+ call('LREM', key, count, value)
130
130
  end
131
131
 
132
132
  # Set the value of an element in a list by its index. O(N) where N is the length of the list. Setting either the first or the last element of the list is O(1).
@@ -135,7 +135,7 @@ module Protocol
135
135
  # @param index [Integer]
136
136
  # @param element [String]
137
137
  def lset(key, index, values)
138
- return call('LSET', key, index, values)
138
+ call('LSET', key, index, values)
139
139
  end
140
140
 
141
141
  # Trim a list to the specified range. O(N) where N is the number of elements to be removed by the operation.
@@ -144,14 +144,14 @@ module Protocol
144
144
  # @param start [Integer]
145
145
  # @param stop [Integer]
146
146
  def ltrim(key, start, stop)
147
- return call('LTRIM', key, start, stop)
147
+ call('LTRIM', key, start, stop)
148
148
  end
149
149
 
150
150
  # Remove and get the last element in a list. O(1).
151
151
  # @see https://redis.io/commands/rpop
152
152
  # @param key [Key]
153
153
  def rpop(key)
154
- return call('RPOP', key)
154
+ call('RPOP', key)
155
155
  end
156
156
 
157
157
  # Remove the last element in a list, prepend it to another list and return it. O(1).
@@ -161,7 +161,7 @@ module Protocol
161
161
  def rpoplpush(source, destination=nil)
162
162
  destination = source if destination.nil?
163
163
 
164
- return call('RPOPLPUSH', source, destination)
164
+ call('RPOPLPUSH', source, destination)
165
165
  end
166
166
 
167
167
  # Append one or multiple elements to a list. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
@@ -176,7 +176,7 @@ module Protocol
176
176
  values = [value] + values
177
177
  end
178
178
 
179
- return call('RPUSH', key, *values)
179
+ call('RPUSH', key, *values)
180
180
  end
181
181
 
182
182
  # Append an element to a list, only if the list exists. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
@@ -184,7 +184,7 @@ module Protocol
184
184
  # @param key [Key]
185
185
  # @param element [String]
186
186
  def rpushx(key, value)
187
- return call('RPUSHX', key, value)
187
+ call('RPUSHX', key, value)
188
188
  end
189
189
  end
190
190
  end
@@ -46,7 +46,7 @@ module Protocol
46
46
  # @see https://redis.io/commands/flushdb
47
47
  # @param async [Enum]
48
48
  def flushdb!
49
- return call('FLUSHDB')
49
+ call('FLUSHDB')
50
50
  end
51
51
  end
52
52
  end
@@ -137,7 +137,7 @@ module Protocol
137
137
  # @param milliseconds [Integer]
138
138
  # @param value [String]
139
139
  def psetex(key, milliseconds, value)
140
- return set key, value, milliseconds: milliseconds
140
+ call('PSETEX', key, milliseconds, value)
141
141
  end
142
142
 
143
143
  # Set the string value of a key. O(1).
@@ -163,7 +163,7 @@ module Protocol
163
163
  arguments << "NX"
164
164
  end
165
165
 
166
- return call('SET', key, value, *arguments)
166
+ call('SET', key, value, *arguments)
167
167
  end
168
168
 
169
169
  # Sets or clears the bit at offset in the string value stored at key. O(1).
@@ -172,7 +172,7 @@ module Protocol
172
172
  # @param offset [Integer]
173
173
  # @param value [Integer]
174
174
  def setbit(key, offset, value)
175
- return call('SETBIT', key, offset, value)
175
+ call('SETBIT', key, offset, value)
176
176
  end
177
177
 
178
178
  # Set the value and expiration of a key. O(1).
@@ -181,7 +181,7 @@ module Protocol
181
181
  # @param seconds [Integer]
182
182
  # @param value [String]
183
183
  def setex(key, seconds, value)
184
- return set key, value, seconds: seconds
184
+ call('SETEX', key, seconds, value)
185
185
  end
186
186
 
187
187
  # Set the value of a key, only if the key does not exist. O(1).
@@ -189,7 +189,7 @@ module Protocol
189
189
  # @param key [Key]
190
190
  # @param value [String]
191
191
  def setnx(key, value)
192
- return set key, value, condition: :nx
192
+ call('SETNX', key, value)
193
193
  end
194
194
 
195
195
  # Overwrite part of a string at key starting at the specified offset. O(1), not counting the time taken to copy the new string in place. Usually, this string is very small so the amortized complexity is O(1). Otherwise, complexity is O(M) with M being the length of the value argument.
@@ -198,14 +198,14 @@ module Protocol
198
198
  # @param offset [Integer]
199
199
  # @param value [String]
200
200
  def setrange(key, offset, value)
201
- return call('SETRANGE', key, offset, value)
201
+ call('SETRANGE', key, offset, value)
202
202
  end
203
203
 
204
204
  # Get the length of the value stored in a key. O(1).
205
205
  # @see https://redis.io/commands/strlen
206
206
  # @param key [Key]
207
207
  def strlen(key)
208
- return call('STRLEN', key)
208
+ call('STRLEN', key)
209
209
  end
210
210
  end
211
211
  end
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Protocol
24
24
  module Redis
25
- VERSION = "0.4.0"
25
+ VERSION = "0.4.1"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams