module Rediska::TransactionCommands
Public Class Methods
in_multi()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 11 def self.in_multi @in_multi ||= Hash.new{|h,k| h[k] = false} end
included(klass)
click to toggle source
# File lib/rediska/transaction_commands.rb, line 5 def self.included(klass) klass.class_eval do def self.queued_commands @queued_commands ||= Hash.new {|h,k| h[k] = [] } end def self.in_multi @in_multi ||= Hash.new{|h,k| h[k] = false} end def queued_commands self.class.queued_commands[database_instance_key] end def queued_commands=(cmds) self.class.queued_commands[database_instance_key] = cmds end def in_multi self.class.in_multi[database_instance_key] end def in_multi=(multi_state) self.class.in_multi[database_instance_key] = multi_state end end end
queued_commands()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 7 def self.queued_commands @queued_commands ||= Hash.new {|h,k| h[k] = [] } end
Public Instance Methods
discard()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 33 def discard unless in_multi raise Redis::CommandError, 'ERR DISCARD without MULTI' end self.in_multi = false self.queued_commands = [] 'OK' end
exec()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 44 def exec unless in_multi raise Redis::CommandError, 'ERR EXEC without MULTI' end responses = queued_commands.map do |cmd| begin send(*cmd) rescue => e e end end self.queued_commands = [] self.in_multi = false responses end
in_multi()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 23 def in_multi self.class.in_multi[database_instance_key] end
in_multi=(multi_state)
click to toggle source
# File lib/rediska/transaction_commands.rb, line 27 def in_multi=(multi_state) self.class.in_multi[database_instance_key] = multi_state end
multi() { |self| ... }
click to toggle source
# File lib/rediska/transaction_commands.rb, line 63 def multi if in_multi raise Redis::CommandError, 'ERR MULTI calls can not be nested' end self.in_multi = true yield(self) if block_given? 'OK' end
queued_commands()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 15 def queued_commands self.class.queued_commands[database_instance_key] end
queued_commands=(cmds)
click to toggle source
# File lib/rediska/transaction_commands.rb, line 19 def queued_commands=(cmds) self.class.queued_commands[database_instance_key] = cmds end
unwatch()
click to toggle source
# File lib/rediska/transaction_commands.rb, line 79 def unwatch 'OK' end
watch(*_)
click to toggle source
# File lib/rediska/transaction_commands.rb, line 75 def watch(*_) 'OK' end