Module: Async::Redis::Client::Methods
- Included in:
- Async::Redis::Client, SentinelClient
- Defined in:
- lib/async/redis/client.rb
Overview
Methods module providing Redis-specific functionality.
Instance Method Summary collapse
-
#call(*arguments) ⇒ Object
Execute a Redis command directly.
-
#close ⇒ Object
Close the client and all its connections.
-
#pipeline(&block) ⇒ Object
(also: #nested)
Execute commands in a pipeline for improved performance.
-
#psubscribe(*patterns) ⇒ Object
Subscribe to one or more channel patterns for pub/sub messaging.
-
#ssubscribe(*channels) ⇒ Object
Subscribe to one or more sharded channels for pub/sub messaging (Redis 7.0+).
-
#subscribe(*channels) ⇒ Object
Subscribe to one or more channels for pub/sub messaging.
-
#transaction(&block) ⇒ Object
(also: #multi)
Execute commands within a Redis transaction.
Instance Method Details
#call(*arguments) ⇒ Object
Execute a Redis command directly.
130 131 132 133 134 135 136 137 138 |
# File 'lib/async/redis/client.rb', line 130 def call(*arguments) @pool.acquire do |connection| connection.write_request(arguments) connection.flush return connection.read_response end end |
#close ⇒ Object
Close the client and all its connections.
141 142 143 |
# File 'lib/async/redis/client.rb', line 141 def close @pool.close end |
#pipeline(&block) ⇒ Object Also known as: nested
Execute commands in a pipeline for improved performance.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/async/redis/client.rb', line 112 def pipeline(&block) context = Context::Pipeline.new(@pool) return context unless block_given? begin yield context ensure context.close end end |
#psubscribe(*patterns) ⇒ Object
Subscribe to one or more channel patterns for pub/sub messaging.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/async/redis/client.rb', line 56 def psubscribe(*patterns) context = Context::Subscription.new(@pool, []) context.psubscribe(patterns) return context unless block_given? begin yield context ensure context.close end end |
#ssubscribe(*channels) ⇒ Object
Subscribe to one or more sharded channels for pub/sub messaging (Redis 7.0+).
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/async/redis/client.rb', line 75 def ssubscribe(*channels) context = Context::Subscription.new(@pool, []) context.ssubscribe(channels) return context unless block_given? begin yield context ensure context.close end end |
#subscribe(*channels) ⇒ Object
Subscribe to one or more channels for pub/sub messaging.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/async/redis/client.rb', line 38 def subscribe(*channels) context = Context::Subscription.new(@pool, channels) return context unless block_given? begin yield context ensure context.close end end |
#transaction(&block) ⇒ Object Also known as: multi
Execute commands within a Redis transaction.
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/async/redis/client.rb', line 93 def transaction(&block) context = Context::Transaction.new(@pool) return context unless block_given? begin yield context ensure context.close end end |