protocol-redis 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,186 +1,187 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2023, by Troex Nevelin.
6
6
  # Copyright, 2023, by Nick Burwell.
7
7
 
8
8
  module Protocol
9
9
  module Redis
10
10
  module Methods
11
+ # Methods for managing Redis hashes.
11
12
  module Hashes
12
13
  # Get the number of fields in a hash. O(1).
13
- # @see https://redis.io/commands/hlen
14
- # @param key [Key]
15
- # @return [Integer]
14
+ # See <https://redis.io/commands/hlen> for more details.
15
+ # @parameter key [Key]
16
+ # @returns [Integer]
16
17
  def hlen(key)
17
- call('HLEN', key)
18
+ call("HLEN", key)
18
19
  end
19
20
 
20
21
  # 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.
21
- # @see https://redis.io/commands/hset
22
- # @param key [Key]
23
- # @return [Integer] if new field added returns "1" otherwise "0"
22
+ # See <https://redis.io/commands/hset> for more details.
23
+ # @parameter key [Key]
24
+ # @returns [Integer] if new field added returns "1" otherwise "0"
24
25
  def hset(key, field, value)
25
- call('HSET', key, field, value)
26
+ call("HSET", key, field, value)
26
27
  end
27
28
 
28
29
  # Set the value of a hash field, only if the field does not exist. O(1).
29
- # @see https://redis.io/commands/hsetnx
30
- # @param key [Key]
31
- # @param field [String]
32
- # @param value [String]
33
- # @return [Boolean] "true" if new field added, "false" otherwise
30
+ # See <https://redis.io/commands/hsetnx> for more details.
31
+ # @parameter key [Key]
32
+ # @parameter field [String]
33
+ # @parameter value [String]
34
+ # @returns [Boolean] "true" if new field added, "false" otherwise
34
35
  def hsetnx(key, field, value)
35
- call('HSETNX', key, field, value) > 0
36
+ call("HSETNX", key, field, value) > 0
36
37
  end
37
38
 
38
39
  # Set multiple hash fields to multiple values. O(N) where N is the number of fields being set.
39
- # @see https://redis.io/commands/hmset
40
- # @param key [Key]
41
- # @return [String] default: "OK"
40
+ # See <https://redis.io/commands/hmset> for more details.
41
+ # @parameter key [Key]
42
+ # @returns [String] default: "OK"
42
43
  def hmset(key, *attrs)
43
- call('HMSET', key, *attrs)
44
+ call("HMSET", key, *attrs)
44
45
  end
45
-
46
+
46
47
  # Set multiple hash fields to multiple values, by providing a hash
47
48
  #
48
49
  # @example
49
50
  # redis.mapped_hmset("hash", { "f1" => "v1", "f2" => "v2" })
50
51
  # # => "OK"
51
52
  #
52
- # @param key [Key]
53
- # @param hash [Hash] a non-empty hash with fields mapping to values
54
- # @return [String] default: "OK"
53
+ # @parameter key [Key]
54
+ # @parameter hash [Hash] a non-empty hash with fields mapping to values
55
+ # @returns [String] default: "OK"
55
56
  #
56
- # @see #hmset
57
+ # See <#hmset> for more details.
57
58
  def mapped_hmset(key, hash)
58
59
  hmset(key, *hash.flatten)
59
60
  end
60
61
 
61
62
  # Get the value of a hash field. O(1).
62
- # @see https://redis.io/commands/hget
63
- # @param key [Key]
64
- # @param field [String]
65
- # @return [String, Null]
63
+ # See <https://redis.io/commands/hget> for more details.
64
+ # @parameter key [Key]
65
+ # @parameter field [String]
66
+ # @returns [String, Null]
66
67
  def hget(key, field)
67
- call('HGET', key, field)
68
+ call("HGET", key, field)
68
69
  end
69
70
 
70
71
  # Get the values of all the given hash fields. O(N) where N is the number of fields being requested.
71
- # @see https://redis.io/commands/hmget
72
- # @param key [Key]
73
- # @param fields [Array<String>] array of fields
74
- # @return [Array]
72
+ # See <https://redis.io/commands/hmget> for more details.
73
+ # @parameter key [Key]
74
+ # @parameter fields [Array(String)] array of fields
75
+ # @returns [Array]
75
76
  def hmget(key, *fields)
76
- call('HMGET', key, *fields)
77
+ call("HMGET", key, *fields)
77
78
  end
78
-
79
+
79
80
  # Get the values of all the given hash fields and return as array
80
81
  #
81
82
  # @example
82
83
  # redis.mapped_hmget("hash", "f1", "f2")
83
84
  # # => { "f1" => "v1", "f2" => "v2" }
84
85
  #
85
- # @param key [Key]
86
- # @param fields [Array<String>] array of fields
87
- # @return [Hash] a hash mapping the specified fields to their values
86
+ # @parameter key [Key]
87
+ # @parameter fields [Array(String)] array of fields
88
+ # @returns [Hash] a hash mapping the specified fields to their values
88
89
  #
89
- # @see #hmget
90
+ # See <#hmget> for more details.
90
91
  def mapped_hmget(key, *fields)
91
92
  reply = hmget(key, *fields)
92
93
  Hash[fields.zip(reply)]
93
94
  end
94
-
95
+
95
96
  # Delete one or more hash fields. O(N) where N is the number of fields to be removed.
96
- # @see https://redis.io/commands/hdel
97
- # @param key [Key]
98
- # @param field [String]
99
- # @return [Integer] number of deleted fields
97
+ # See <https://redis.io/commands/hdel> for more details.
98
+ # @parameter key [Key]
99
+ # @parameter field [String]
100
+ # @returns [Integer] number of deleted fields
100
101
  def hdel(key, *fields)
101
- call('HDEL', key, *fields)
102
+ call("HDEL", key, *fields)
102
103
  end
103
104
 
104
105
  # Determine if a hash field exists. O(1).
105
- # @see https://redis.io/commands/hexists
106
- # @param key [Key]
107
- # @param field [String]
108
- # @return [Boolean]
106
+ # See <https://redis.io/commands/hexists> for more details.
107
+ # @parameter key [Key]
108
+ # @parameter field [String]
109
+ # @returns [Boolean]
109
110
  def hexists(key, field)
110
- call('HEXISTS', key, field) > 0
111
+ call("HEXISTS", key, field) > 0
111
112
  end
112
113
 
113
114
  # Increment the integer value of a hash field by the given number. O(1).
114
- # @see https://redis.io/commands/hincrby
115
- # @param key [Key]
116
- # @param field [String]
117
- # @param increment [Integer]
118
- # @return [Integer] field value after increment
115
+ # See <https://redis.io/commands/hincrby> for more details.
116
+ # @parameter key [Key]
117
+ # @parameter field [String]
118
+ # @parameter increment [Integer]
119
+ # @returns [Integer] field value after increment
119
120
  def hincrby(key, field, increment)
120
- call('HINCRBY', key, field, increment)
121
+ call("HINCRBY", key, field, increment)
121
122
  end
122
123
 
123
124
  # Increment the float value of a hash field by the given amount. O(1).
124
- # @see https://redis.io/commands/hincrbyfloat
125
- # @param key [Key]
126
- # @param field [String]
127
- # @param increment [Double]
128
- # @return [Float] field value after increment
125
+ # See <https://redis.io/commands/hincrbyfloat> for more details.
126
+ # @parameter key [Key]
127
+ # @parameter field [String]
128
+ # @parameter increment [Double]
129
+ # @returns [Float] field value after increment
129
130
  def hincrbyfloat(key, field, increment)
130
- Float(call('HINCRBYFLOAT', key, field, increment))
131
+ Float(call("HINCRBYFLOAT", key, field, increment))
131
132
  end
132
133
 
133
134
  # Get all the fields in a hash. O(N) where N is the size of the hash.
134
- # @see https://redis.io/commands/hkeys
135
- # @param key [Key]
136
- # @return [Array]
135
+ # See <https://redis.io/commands/hkeys> for more details.
136
+ # @parameter key [Key]
137
+ # @returns [Array]
137
138
  def hkeys(key)
138
- call('HKEYS', key)
139
+ call("HKEYS", key)
139
140
  end
140
141
 
141
142
  # Get all the values in a hash. O(N) where N is the size of the hash.
142
- # @see https://redis.io/commands/hvals
143
- # @param key [Key]
144
- # @return [Array]
143
+ # See <https://redis.io/commands/hvals> for more details.
144
+ # @parameter key [Key]
145
+ # @returns [Array]
145
146
  def hvals(key)
146
- call('HVALS', key)
147
+ call("HVALS", key)
147
148
  end
148
149
 
149
150
  # Get all the fields and values in a hash. O(N) where N is the size of the hash.
150
- # @see https://redis.io/commands/hgetall
151
- # @param key [Key]
152
- # @return [Hash]
151
+ # See <https://redis.io/commands/hgetall> for more details.
152
+ # @parameter key [Key]
153
+ # @returns [Hash]
153
154
  def hgetall(key)
154
- call('HGETALL', key).each_slice(2).to_h
155
+ call("HGETALL", key).each_slice(2).to_h
155
156
  end
156
-
157
+
157
158
  # Iterates fields of Hash types and their associated values. 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.
158
- # @see https://redis.io/commands/hscan/
159
- # @param cursor [Cursor]
160
- # @return [Hash]
159
+ # See <https://redis.io/commands/hscan/> for more details.
160
+ # @parameter cursor [Cursor]
161
+ # @returns [Hash]
161
162
  def hscan(key, cursor = "0", match: nil, count: nil)
162
163
  arguments = [key, cursor]
163
-
164
+
164
165
  if match
165
166
  arguments.append("MATCH", match)
166
167
  end
167
-
168
+
168
169
  if count
169
170
  arguments.append("COUNT", count)
170
171
  end
171
-
172
+
172
173
  call("HSCAN", *arguments)
173
174
  end
174
175
 
175
176
  # Iterate over each field and the value of the hash, using HSCAN.
176
177
  def hscan_each(key, cursor = "0", match: nil, count: nil, &block)
177
178
  return enum_for(:hscan_each, key, cursor, match: match, count: count) unless block_given?
178
-
179
+
179
180
  while true
180
181
  cursor, data = hscan(key, cursor, match: match, count: count)
181
-
182
+
182
183
  data.each_slice(2, &block)
183
-
184
+
184
185
  break if cursor == "0"
185
186
  end
186
187
  end
@@ -7,74 +7,75 @@
7
7
  module Protocol
8
8
  module Redis
9
9
  module Methods
10
+ # Methods for managing Redis lists.
10
11
  module Lists
11
12
  # Remove and get the first element in a list, or block until one is available. O(1).
12
- # @see https://redis.io/commands/blpop
13
- # @param key [Key]
14
- # @param timeout [Integer]
13
+ # See <https://redis.io/commands/blpop> for more details.
14
+ # @parameter key [Key]
15
+ # @parameter timeout [Integer]
15
16
  def blpop(*keys, timeout: 0)
16
- call('BLPOP', *keys, timeout)
17
+ call("BLPOP", *keys, timeout)
17
18
  end
18
19
 
19
20
  # Remove and get the last element in a list, or block until one is available. O(1).
20
- # @see https://redis.io/commands/brpop
21
- # @param key [Key]
22
- # @param timeout [Integer]
21
+ # See <https://redis.io/commands/brpop> for more details.
22
+ # @parameter key [Key]
23
+ # @parameter timeout [Integer]
23
24
  def brpop(*keys, timeout: 0)
24
- call('BRPOP', *keys, timeout)
25
+ call("BRPOP", *keys, timeout)
25
26
  end
26
27
 
27
28
  # Pop an element from a list, push it to another list and return it; or block until one is available. O(1).
28
- # @see https://redis.io/commands/brpoplpush
29
- # @param source [Key]
30
- # @param destination [Key]
31
- # @param timeout [Integer]
29
+ # See <https://redis.io/commands/brpoplpush> for more details.
30
+ # @parameter source [Key]
31
+ # @parameter destination [Key]
32
+ # @parameter timeout [Integer]
32
33
  def brpoplpush(source, destination, timeout)
33
- call('BRPOPLPUSH', source, destination, timeout)
34
+ call("BRPOPLPUSH", source, destination, timeout)
34
35
  end
35
36
 
36
37
  # 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).
37
- # @see https://redis.io/commands/lindex
38
- # @param key [Key]
39
- # @param index [Integer]
38
+ # See <https://redis.io/commands/lindex> for more details.
39
+ # @parameter key [Key]
40
+ # @parameter index [Integer]
40
41
  def lindex(key, index)
41
- call('LINDEX', key, index)
42
+ call("LINDEX", key, index)
42
43
  end
43
44
 
44
45
  # 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).
45
- # @see https://redis.io/commands/linsert
46
- # @param key [Key]
47
- # @param where [Enum]
48
- # @param pivot [String]
49
- # @param element [String]
46
+ # See <https://redis.io/commands/linsert> for more details.
47
+ # @parameter key [Key]
48
+ # @parameter where [Enum]
49
+ # @parameter pivot [String]
50
+ # @parameter element [String]
50
51
  def linsert(key, position=:before, index, value)
51
52
  if position == :before
52
- offset = 'BEFORE'
53
+ offset = "BEFORE"
53
54
  else
54
- offset = 'AFTER'
55
+ offset = "AFTER"
55
56
  end
56
57
 
57
- call('LINSERT', key, offset, index, value)
58
+ call("LINSERT", key, offset, index, value)
58
59
  end
59
60
 
60
61
  # Get the length of a list. O(1).
61
- # @see https://redis.io/commands/llen
62
- # @param key [Key]
62
+ # See <https://redis.io/commands/llen> for more details.
63
+ # @parameter key [Key]
63
64
  def llen(key)
64
- call('LLEN', key)
65
+ call("LLEN", key)
65
66
  end
66
67
 
67
68
  # Remove and get the first element in a list. O(1).
68
- # @see https://redis.io/commands/lpop
69
- # @param key [Key]
69
+ # See <https://redis.io/commands/lpop> for more details.
70
+ # @parameter key [Key]
70
71
  def lpop(key)
71
- call('LPOP', key)
72
+ call("LPOP", key)
72
73
  end
73
74
 
74
75
  # 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.
75
- # @see https://redis.io/commands/lpush
76
- # @param key [Key]
77
- # @param element [String]
76
+ # See <https://redis.io/commands/lpush> for more details.
77
+ # @parameter key [Key]
78
+ # @parameter element [String]
78
79
  def lpush(key, value, *values)
79
80
  case value
80
81
  when Array
@@ -83,74 +84,74 @@ module Protocol
83
84
  values = [value] + values
84
85
  end
85
86
 
86
- call('LPUSH', key, *values)
87
+ call("LPUSH", key, *values)
87
88
  end
88
89
 
89
90
  # 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.
90
- # @see https://redis.io/commands/lpushx
91
- # @param key [Key]
92
- # @param element [String]
91
+ # See <https://redis.io/commands/lpushx> for more details.
92
+ # @parameter key [Key]
93
+ # @parameter element [String]
93
94
  def lpushx(key, value)
94
- call('LPUSHX', key, value)
95
+ call("LPUSHX", key, value)
95
96
  end
96
97
 
97
98
  # 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.
98
- # @see https://redis.io/commands/lrange
99
- # @param key [Key]
100
- # @param start [Integer]
101
- # @param stop [Integer]
99
+ # See <https://redis.io/commands/lrange> for more details.
100
+ # @parameter key [Key]
101
+ # @parameter start [Integer]
102
+ # @parameter stop [Integer]
102
103
  def lrange(key, start, stop)
103
- call('LRANGE', key, start, stop)
104
+ call("LRANGE", key, start, stop)
104
105
  end
105
106
 
106
107
  # Remove elements from a list. O(N+M) where N is the length of the list and M is the number of elements removed.
107
- # @see https://redis.io/commands/lrem
108
- # @param key [Key]
109
- # @param count [Integer]
110
- # @param element [String]
108
+ # See <https://redis.io/commands/lrem> for more details.
109
+ # @parameter key [Key]
110
+ # @parameter count [Integer]
111
+ # @parameter element [String]
111
112
  def lrem(key, count, value)
112
- call('LREM', key, count, value)
113
+ call("LREM", key, count, value)
113
114
  end
114
115
 
115
116
  # 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).
116
- # @see https://redis.io/commands/lset
117
- # @param key [Key]
118
- # @param index [Integer]
119
- # @param element [String]
117
+ # See <https://redis.io/commands/lset> for more details.
118
+ # @parameter key [Key]
119
+ # @parameter index [Integer]
120
+ # @parameter element [String]
120
121
  def lset(key, index, values)
121
- call('LSET', key, index, values)
122
+ call("LSET", key, index, values)
122
123
  end
123
124
 
124
125
  # Trim a list to the specified range. O(N) where N is the number of elements to be removed by the operation.
125
- # @see https://redis.io/commands/ltrim
126
- # @param key [Key]
127
- # @param start [Integer]
128
- # @param stop [Integer]
126
+ # See <https://redis.io/commands/ltrim> for more details.
127
+ # @parameter key [Key]
128
+ # @parameter start [Integer]
129
+ # @parameter stop [Integer]
129
130
  def ltrim(key, start, stop)
130
- call('LTRIM', key, start, stop)
131
+ call("LTRIM", key, start, stop)
131
132
  end
132
133
 
133
134
  # Remove and get the last element in a list. O(1).
134
- # @see https://redis.io/commands/rpop
135
- # @param key [Key]
135
+ # See <https://redis.io/commands/rpop> for more details.
136
+ # @parameter key [Key]
136
137
  def rpop(key)
137
- call('RPOP', key)
138
+ call("RPOP", key)
138
139
  end
139
140
 
140
141
  # Remove the last element in a list, prepend it to another list and return it. O(1).
141
- # @see https://redis.io/commands/rpoplpush
142
- # @param source [Key]
143
- # @param destination [Key]
142
+ # See <https://redis.io/commands/rpoplpush> for more details.
143
+ # @parameter source [Key]
144
+ # @parameter destination [Key]
144
145
  def rpoplpush(source, destination=nil)
145
146
  destination = source if destination.nil?
146
147
 
147
- call('RPOPLPUSH', source, destination)
148
+ call("RPOPLPUSH", source, destination)
148
149
  end
149
150
 
150
151
  # 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.
151
- # @see https://redis.io/commands/rpush
152
- # @param key [Key]
153
- # @param element [String]
152
+ # See <https://redis.io/commands/rpush> for more details.
153
+ # @parameter key [Key]
154
+ # @parameter element [String]
154
155
  def rpush(key, value, *values)
155
156
  case value
156
157
  when Array
@@ -159,15 +160,15 @@ module Protocol
159
160
  values = [value] + values
160
161
  end
161
162
 
162
- call('RPUSH', key, *values)
163
+ call("RPUSH", key, *values)
163
164
  end
164
165
 
165
166
  # 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.
166
- # @see https://redis.io/commands/rpushx
167
- # @param key [Key]
168
- # @param element [String]
167
+ # See <https://redis.io/commands/rpushx> for more details.
168
+ # @parameter key [Key]
169
+ # @parameter element [String]
169
170
  def rpushx(key, value)
170
- call('RPUSHX', key, value)
171
+ call("RPUSHX", key, value)
171
172
  end
172
173
  end
173
174
  end
@@ -6,13 +6,14 @@
6
6
  module Protocol
7
7
  module Redis
8
8
  module Methods
9
+ # Methods for managing Redis Pub/Sub.
9
10
  module Pubsub
10
11
  # Post a message to a channel.
11
- # @see https://redis.io/commands/publish
12
- # @param channel [String]
13
- # @param message [String]
12
+ # See <https://redis.io/commands/publish> for more details.
13
+ # @parameter channel [String]
14
+ # @parameter message [String]
14
15
  def publish(channel, message)
15
- call('PUBLISH', channel, message)
16
+ call("PUBLISH", channel, message)
16
17
  end
17
18
  end
18
19
  end
@@ -7,31 +7,32 @@
7
7
  module Protocol
8
8
  module Redis
9
9
  module Methods
10
+ # Mehtods for managing Redis scripting.
10
11
  module Scripting
11
12
  # Execute a Lua script server side. Depends on the script that is executed.
12
- # @see https://redis.io/commands/eval
13
- # @param script [String]
14
- # @param numkeys [Integer]
15
- # @param key [Key] Multiple keys are supported, as long as the same number of values are also provided
16
- # @param arg [String]
13
+ # See <https://redis.io/commands/eval> for more details.
14
+ # @parameter script [String]
15
+ # @parameter numkeys [Integer]
16
+ # @parameter key [Key] Multiple keys are supported, as long as the same number of values are also provided
17
+ # @parameter arg [String]
17
18
  def eval(*arguments)
18
19
  call("EVAL", *arguments)
19
20
  end
20
21
 
21
22
  # Execute a Lua script server side. Depends on the script that is executed.
22
- # @see https://redis.io/commands/evalsha
23
- # @param sha1 [String]
24
- # @param numkeys [Integer]
25
- # @param key [Key]
26
- # @param arg [String]
23
+ # See <https://redis.io/commands/evalsha> for more details.
24
+ # @parameter sha1 [String]
25
+ # @parameter numkeys [Integer]
26
+ # @parameter key [Key]
27
+ # @parameter arg [String]
27
28
  def evalsha(*arguments)
28
29
  call("EVALSHA", *arguments)
29
30
  end
30
31
 
31
32
  # Execute script management commands
32
- # @see https://redis.io/commands/script/
33
- # @param subcommand [String] e.g. `debug`, `exists`, `flush`, `load`, `kill`
34
- # @param [Array<String>] args depends on the subcommand provided
33
+ # See <https://redis.io/commands/script/> for more details.
34
+ # @parameter subcommand [String] e.g. `debug`, `exists`, `flush`, `load`, `kill`
35
+ # @parameter [Array(String)] arguments depends on the subcommand provided
35
36
  def script(subcommand, *arguments)
36
37
  call("SCRIPT", subcommand.to_s, *arguments)
37
38
  end
@@ -1,21 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2020, by David Ortiz.
6
6
 
7
7
  module Protocol
8
8
  module Redis
9
9
  module Methods
10
+ # Methods for managing Redis servers.
10
11
  module Server
11
12
  # Get information and statistics about the server.
12
- # @see https://redis.io/commands/info
13
- # @param section [String]
13
+ # See <https://redis.io/commands/info> for more details.
14
+ # @parameter section [String]
14
15
  def info
15
16
  metadata = {}
16
17
 
17
- call('INFO').each_line(Redis::Connection::CRLF) do |line|
18
- key, value = line.split(':')
18
+ call("INFO").each_line(Redis::Connection::CRLF) do |line|
19
+ key, value = line.split(":")
19
20
 
20
21
  if value
21
22
  metadata[key.to_sym] = value.chomp!
@@ -25,11 +26,30 @@ module Protocol
25
26
  return metadata
26
27
  end
27
28
 
29
+ # Get the client information for the current connection.
30
+ # See <https://redis.io/commands/client-info> for more details.
31
+ # @returns [Hash] A hash containing client metadata.
32
+ def client_info
33
+ metadata = {}
34
+
35
+ call("CLIENT", "INFO").split(/\s+/).each do |pair|
36
+ key, value = pair.split("=")
37
+
38
+ if value
39
+ metadata[key.to_sym] = value
40
+ else
41
+ metadata[key.to_sym] = nil
42
+ end
43
+ end
44
+
45
+ return metadata
46
+ end
47
+
28
48
  # Remove all keys from the current database.
29
- # @see https://redis.io/commands/flushdb
30
- # @param async [Enum]
49
+ # See <https://redis.io/commands/flushdb> for more details.
50
+ # @parameter async [Enum]
31
51
  def flushdb!
32
- call('FLUSHDB')
52
+ call("FLUSHDB")
33
53
  end
34
54
  end
35
55
  end