Skip to content

Commit

Permalink
Merge pull request #1269 from FujiokaD/doc/write_redis_doc_url
Browse files Browse the repository at this point in the history
doc: add redis doc URL written acceptable regular expressions patterns
  • Loading branch information
byroot authored Apr 23, 2024
2 parents f236b12 + fd69ea0 commit a06456c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/redis/commands/hashes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def hgetall(key)
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<[String, String]>] the next cursor and all found keys
#
# See the [Redis Server HSCAN documentation](https://redis.io/docs/latest/commands/hscan/) for further details
def hscan(key, cursor, **options)
_scan(:hscan, cursor, [key], **options) do |reply|
[reply[0], reply[1].each_slice(2).to_a]
Expand All @@ -239,6 +241,8 @@ def hscan(key, cursor, **options)
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all found keys
#
# See the [Redis Server HSCAN documentation](https://redis.io/docs/latest/commands/hscan/) for further details
def hscan_each(key, **options, &block)
return to_enum(:hscan_each, key, **options) unless block_given?

Expand Down
6 changes: 6 additions & 0 deletions lib/redis/commands/keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module Keys
# - `:type => String`: return keys only of the given type
#
# @return [String, Array<String>] the next cursor and all found keys
#
# See the [Redis Server SCAN documentation](https://redis.io/docs/latest/commands/scan/) for further details
def scan(cursor, **options)
_scan(:scan, cursor, [], **options)
end
Expand All @@ -46,6 +48,8 @@ def scan(cursor, **options)
# - `:type => String`: return keys only of the given type
#
# @return [Enumerator] an enumerator for all found keys
#
# See the [Redis Server SCAN documentation](https://redis.io/docs/latest/commands/scan/) for further details
def scan_each(**options, &block)
return to_enum(:scan_each, **options) unless block_given?

Expand Down Expand Up @@ -282,6 +286,8 @@ def exists?(*keys)
#
# @param [String] pattern
# @return [Array<String>]
#
# See the [Redis Server KEYS documentation](https://redis.io/docs/latest/commands/keys/) for further details
def keys(pattern = "*")
send_command([:keys, pattern]) do |reply|
if reply.is_a?(String)
Expand Down
3 changes: 3 additions & 0 deletions lib/redis/commands/pubsub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ def unsubscribe(*channels)
end

# Listen for messages published to channels matching the given patterns.
# See the [Redis Server PSUBSCRIBE documentation](https://redis.io/docs/latest/commands/psubscribe/) for further details
def psubscribe(*channels, &block)
_subscription(:psubscribe, 0, channels, block)
end

# Listen for messages published to channels matching the given patterns.
# Throw a timeout error if there is no messages for a timeout period.
# See the [Redis Server PSUBSCRIBE documentation](https://redis.io/docs/latest/commands/psubscribe/) for further details
def psubscribe_with_timeout(timeout, *channels, &block)
_subscription(:psubscribe_with_timeout, timeout, channels, block)
end

# Stop listening for messages posted to channels matching the given patterns.
# See the [Redis Server PUNSUBSCRIBE documentation](https://redis.io/docs/latest/commands/punsubscribe/) for further details
def punsubscribe(*channels)
_subscription(:punsubscribe, 0, channels, nil)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/redis/commands/sets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def sunionstore(destination, *keys)
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<String>] the next cursor and all found members
#
# See the [Redis Server SSCAN documentation](https://redis.io/docs/latest/commands/sscan/) for further details
def sscan(key, cursor, **options)
_scan(:sscan, cursor, [key], **options)
end
Expand All @@ -199,6 +201,8 @@ def sscan(key, cursor, **options)
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all keys in the set
#
# See the [Redis Server SSCAN documentation](https://redis.io/docs/latest/commands/sscan/) for further details
def sscan_each(key, **options, &block)
return to_enum(:sscan_each, key, **options) unless block_given?

Expand Down
4 changes: 4 additions & 0 deletions lib/redis/commands/sorted_sets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ def zdiffstore(*args)
#
# @return [String, Array<[String, Float]>] the next cursor and all found
# members and scores
#
# See the [Redis Server ZSCAN documentation](https://redis.io/docs/latest/commands/zscan/) for further details
def zscan(key, cursor, **options)
_scan(:zscan, cursor, [key], **options) do |reply|
[reply[0], FloatifyPairs.call(reply[1])]
Expand All @@ -834,6 +836,8 @@ def zscan(key, cursor, **options)
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all found scores and members
#
# See the [Redis Server ZSCAN documentation](https://redis.io/docs/latest/commands/zscan/) for further details
def zscan_each(key, **options, &block)
return to_enum(:zscan_each, key, **options) unless block_given?

Expand Down
2 changes: 2 additions & 0 deletions lib/redis/distributed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -948,12 +948,14 @@ def unsubscribe(*channels)
end

# Listen for messages published to channels matching the given patterns.
# See the [Redis Server PSUBSCRIBE documentation](https://redis.io/docs/latest/commands/psubscribe/) for further details
def psubscribe(*channels, &block)
raise NotImplementedError
end

# Stop listening for messages posted to channels matching the given
# patterns.
# See the [Redis Server PUNSUBSCRIBE documentation](https://redis.io/docs/latest/commands/punsubscribe/) for further details
def punsubscribe(*channels)
raise NotImplementedError
end
Expand Down

0 comments on commit a06456c

Please sign in to comment.