Methods module providing Redis-specific functionality.
Definitionsdef subscribe(*channels)
Subscribe to one or more channels for pub/sub messaging.
Signaturechannels
Array(String)
The channels to subscribe to.
{|context| ...}
If a block is given, it will be executed within the subscription context.
context
Context::Subscribe
The subscription context.
Object
The result of the block if block given.
Context::Subscribe
The subscription context if no block given.
def subscribe(*channels)
context = Context::Subscribe.new(@pool, channels)
return context unless block_given?
begin
yield context
ensure
context.close
end
end
def transaction(&block)
Execute commands within a Redis transaction.
Signature{|context| ...}
If a block is given, it will be executed within the transaction context.
context
Context::Transaction
The transaction context.
Object
The result of the block if block given.
Context::Transaction
Else if no block is given, returns the transaction context.
def transaction(&block)
context = Context::Transaction.new(@pool)
return context unless block_given?
begin
yield context
ensure
context.close
end
end
def pipeline(&block)
Execute commands in a pipeline for improved performance.
Signature{|context| ...}
If a block is given, it will be executed within the pipeline context.
context
Context::Pipeline
The pipeline context.
Object
The result of the block if block given.
Context::Pipeline
The pipeline context if no block given.
def pipeline(&block)
context = Context::Pipeline.new(@pool)
return context unless block_given?
begin
yield context
ensure
context.close
end
end
def call(*arguments)
Execute a Redis command directly.
Signaturearguments
Array
The command and its arguments.
Object
The response from the Redis server.
def call(*arguments)
@pool.acquire do |connection|
connection.write_request(arguments)
connection.flush
return connection.read_response
end
end
def close
Close the client and all its connections.
Implementationdef close
@pool.close
end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4