Class: Async::Redis::Context::Transaction

Inherits:
Pipeline show all
Defined in:
lib/async/redis/context/transaction.rb

Overview

Context for Redis transaction operations using MULTI/EXEC.

Instance Method Summary collapse

Methods inherited from Pipeline

#call, #close, #collect, #flush, #read_response, #sync, #write_request

Methods inherited from Generic

#call, #close, #closed?, #read_response, #write_request

Constructor Details

#initialize(pool, *arguments) ⇒ Transaction

Initialize a new transaction context.



17
18
19
# File 'lib/async/redis/context/transaction.rb', line 17

def initialize(pool, *arguments)
	super(pool)
end

Instance Method Details

#discardObject

Discard all queued commands in the transaction.



38
39
40
# File 'lib/async/redis/context/transaction.rb', line 38

def discard
	sync.call("DISCARD")
end

#executeObject

Execute all queued commands, provided that no watched keys have been modified. It's important to note that even when a command fails, all the other commands in the queue are processed – Redis will not stop the processing of commands.



33
34
35
# File 'lib/async/redis/context/transaction.rb', line 33

def execute
	sync.call("EXEC")
end

#multiObject

Begin a transaction block.



22
23
24
# File 'lib/async/redis/context/transaction.rb', line 22

def multi
	call("MULTI")
end

#watch(*keys) ⇒ Object

Watch keys for changes during the transaction.



28
29
30
# File 'lib/async/redis/context/transaction.rb', line 28

def watch(*keys)
	sync.call("WATCH", *keys)
end