protocol-redis 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protocol/redis/methods/strings.rb +18 -15
- data/lib/protocol/redis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b27fc5c9284df516083590216e58a3a16aa1013c90c86414989b29323f818d7c
|
4
|
+
data.tar.gz: f30c545712ff3f82e8eb7de43c4351acf2fdd468e42fd187db2b759580d33fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd00040f3332fa804f1870e4458731fcb3a1275a31bb87cefc6d85fc3036fa4190adc1040bf012f4feeb7655a37b2b5cef0c90ecbced7facc2ce07502556562
|
7
|
+
data.tar.gz: 0a1c2700b7e5655be9822e5166cd433a9c4c4d93f29fa1cea095bca72ce29af065378f25f6fef9d0b832a517af6595c33b08605298f848d562bede903381bb3f
|
@@ -30,21 +30,21 @@ module Protocol
|
|
30
30
|
# @param key [Key]
|
31
31
|
# @param value [String]
|
32
32
|
def append(key, value)
|
33
|
-
|
33
|
+
call('APPEND', key, value)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Count set bits in a string. O(N).
|
37
37
|
# @see https://redis.io/commands/bitcount
|
38
38
|
# @param key [Key]
|
39
39
|
def bitcount(key, *range)
|
40
|
-
|
40
|
+
call('BITCOUNT', key, *range)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Decrement the integer value of a key by one. O(1).
|
44
44
|
# @see https://redis.io/commands/decr
|
45
45
|
# @param key [Key]
|
46
46
|
def decr(key)
|
47
|
-
|
47
|
+
call('DECR', key)
|
48
48
|
end
|
49
49
|
|
50
50
|
# Decrement the integer value of a key by the given number. O(1).
|
@@ -52,14 +52,14 @@ module Protocol
|
|
52
52
|
# @param key [Key]
|
53
53
|
# @param decrement [Integer]
|
54
54
|
def decrby(key, decrement)
|
55
|
-
|
55
|
+
call('DECRBY', key, decrement)
|
56
56
|
end
|
57
57
|
|
58
58
|
# Get the value of a key. O(1).
|
59
59
|
# @see https://redis.io/commands/get
|
60
60
|
# @param key [Key]
|
61
61
|
def get(key)
|
62
|
-
|
62
|
+
call('GET', key)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Returns the bit value at offset in the string value stored at key. O(1).
|
@@ -67,7 +67,7 @@ module Protocol
|
|
67
67
|
# @param key [Key]
|
68
68
|
# @param offset [Integer]
|
69
69
|
def getbit(key, offset)
|
70
|
-
|
70
|
+
call('GETBIT', key, offset)
|
71
71
|
end
|
72
72
|
|
73
73
|
# Get a substring of the string stored at a key. O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.
|
@@ -76,7 +76,7 @@ module Protocol
|
|
76
76
|
# @param start [Integer]
|
77
77
|
# @param end [Integer]
|
78
78
|
def getrange(key, start_index, end_index)
|
79
|
-
|
79
|
+
call('GETRANGE', key, start_index, end_index)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Set the string value of a key and return its old value. O(1).
|
@@ -84,14 +84,14 @@ module Protocol
|
|
84
84
|
# @param key [Key]
|
85
85
|
# @param value [String]
|
86
86
|
def getset(key, value)
|
87
|
-
|
87
|
+
call('GETSET', key, value)
|
88
88
|
end
|
89
89
|
|
90
90
|
# Increment the integer value of a key by one. O(1).
|
91
91
|
# @see https://redis.io/commands/incr
|
92
92
|
# @param key [Key]
|
93
93
|
def incr(key)
|
94
|
-
|
94
|
+
call('INCR', key)
|
95
95
|
end
|
96
96
|
|
97
97
|
# Increment the integer value of a key by the given amount. O(1).
|
@@ -99,7 +99,7 @@ module Protocol
|
|
99
99
|
# @param key [Key]
|
100
100
|
# @param increment [Integer]
|
101
101
|
def incrby(key, increment)
|
102
|
-
|
102
|
+
call('INCRBY', key, increment)
|
103
103
|
end
|
104
104
|
|
105
105
|
# Increment the float value of a key by the given amount. O(1).
|
@@ -107,28 +107,30 @@ module Protocol
|
|
107
107
|
# @param key [Key]
|
108
108
|
# @param increment [Double]
|
109
109
|
def incrbyfloat(key, increment)
|
110
|
-
|
110
|
+
call('INCRBYFLOAT', key, increment)
|
111
111
|
end
|
112
112
|
|
113
113
|
# Get the values of all the given keys. O(N) where N is the number of keys to retrieve.
|
114
114
|
# @see https://redis.io/commands/mget
|
115
115
|
# @param key [Key]
|
116
116
|
def mget(key, *keys)
|
117
|
-
|
117
|
+
call('MGET', key, *keys)
|
118
118
|
end
|
119
119
|
|
120
120
|
# Set multiple keys to multiple values. O(N) where N is the number of keys to set.
|
121
121
|
# @see https://redis.io/commands/mset
|
122
122
|
def mset(pairs)
|
123
123
|
flattened_pairs = pairs.keys.zip(pairs.values).flatten
|
124
|
-
|
124
|
+
|
125
|
+
call('MSET', *flattened_pairs)
|
125
126
|
end
|
126
127
|
|
127
128
|
# Set multiple keys to multiple values, only if none of the keys exist. O(N) where N is the number of keys to set.
|
128
129
|
# @see https://redis.io/commands/msetnx
|
129
130
|
def msetnx(pairs)
|
130
131
|
flattened_pairs = pairs.keys.zip(pairs.values).flatten
|
131
|
-
|
132
|
+
|
133
|
+
call('MSETNX', *flattened_pairs)
|
132
134
|
end
|
133
135
|
|
134
136
|
# Set the value and expiration in milliseconds of a key. O(1).
|
@@ -185,11 +187,12 @@ module Protocol
|
|
185
187
|
end
|
186
188
|
|
187
189
|
# Set the value of a key, only if the key does not exist. O(1).
|
190
|
+
# @return [Boolean] if the key was set.
|
188
191
|
# @see https://redis.io/commands/setnx
|
189
192
|
# @param key [Key]
|
190
193
|
# @param value [String]
|
191
194
|
def setnx(key, value)
|
192
|
-
call('SETNX', key, value)
|
195
|
+
call('SETNX', key, value) == 1
|
193
196
|
end
|
194
197
|
|
195
198
|
# 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.
|