Class: RedisWmrs::Dispatcher
- Inherits:
-
Object
- Object
- RedisWmrs::Dispatcher
- Extended by:
- Forwardable
- Defined in:
- lib/redis_wmrs/dispatcher.rb
Constant Summary collapse
- MASTER_SLAVE_COMMANDS =
[ :select, :quit, ].freeze
- DEFAULT_SLAVE_COMMANDS =
[ :info, # :sync, :dbsize, :lastsave, :time, :ttl, :pttl, :exists, :keys, :randomkey, :type, :get, :mget, :getrange, :getbit, :bitcount, :getset, :strlen, :llen, :lindex, :srandmember, :sismember, :smembers, :sdiff, :sinter, :sunion, :zcard, :zscore, :zrange, :zrevrange, :zrank, :zrevrank, :zrangebyscore, :zrevrangebyscore, :zremrangebyscore, :zcount, :hlen, :hget, :hmget, :hexists, :hkeys, :hvals, :hgetall, # :watch, :unwatch, :echo, :ping ].freeze
Instance Attribute Summary collapse
-
#master ⇒ Object
readonly
Returns the value of attribute master.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#slave ⇒ Object
readonly
Returns the value of attribute slave.
Instance Method Summary collapse
- #call(command, &block) ⇒ Object
- #call_loop(command, &block) ⇒ Object
- #call_with_timeout(command, timeout, &blk) ⇒ Object
- #call_without_timeout(command, &blk) ⇒ Object
- #connect ⇒ Object
- #db=(db) ⇒ Object
- #disconnect ⇒ Object
- #ids ⇒ Object
-
#initialize(master, slave, options) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #locations ⇒ Object
- #logger=(v) ⇒ Object
- #reconnect ⇒ Object
Constructor Details
#initialize(master, slave, options) ⇒ Dispatcher
Returns a new instance of Dispatcher.
28 29 30 31 32 |
# File 'lib/redis_wmrs/dispatcher.rb', line 28 def initialize(master, slave, ) @master, @slave = master, slave @both_cmds = [:both] || MASTER_SLAVE_COMMANDS @slave_cmds = [:slave] || DEFAULT_SLAVE_COMMANDS end |
Instance Attribute Details
#master ⇒ Object (readonly)
Returns the value of attribute master.
25 26 27 |
# File 'lib/redis_wmrs/dispatcher.rb', line 25 def master @master end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/redis_wmrs/dispatcher.rb', line 26 def @options end |
#slave ⇒ Object (readonly)
Returns the value of attribute slave.
25 26 27 |
# File 'lib/redis_wmrs/dispatcher.rb', line 25 def slave @slave end |
Instance Method Details
#call(command, &block) ⇒ Object
54 55 56 |
# File 'lib/redis_wmrs/dispatcher.rb', line 54 def call(command, &block) __dispatch__(*command){|c|c.call(command, &block)} end |
#call_loop(command, &block) ⇒ Object
58 59 60 |
# File 'lib/redis_wmrs/dispatcher.rb', line 58 def call_loop(command, &block) __dispatch__(*command){|c|c.call_loop(command, &block)} end |
#call_with_timeout(command, timeout, &blk) ⇒ Object
62 63 64 |
# File 'lib/redis_wmrs/dispatcher.rb', line 62 def call_with_timeout(command, timeout, &blk) __dispatch__(*command){|c|c.call_with_timeout(command, timeout, &blk)} end |
#call_without_timeout(command, &blk) ⇒ Object
66 67 68 |
# File 'lib/redis_wmrs/dispatcher.rb', line 66 def call_without_timeout(command, &blk) __dispatch__(*command){|c|c.call_without_timeout(command, &blk)} end |
#connect ⇒ Object
50 |
# File 'lib/redis_wmrs/dispatcher.rb', line 50 def connect ; __both__{|c| c.connect }; return self; end |
#db=(db) ⇒ Object
42 43 44 |
# File 'lib/redis_wmrs/dispatcher.rb', line 42 def db=(db) __both__{|c| c.db = db}; return db end |
#disconnect ⇒ Object
51 |
# File 'lib/redis_wmrs/dispatcher.rb', line 51 def disconnect; __both__{|c| c.disconnect}; return self; end |
#ids ⇒ Object
34 35 36 |
# File 'lib/redis_wmrs/dispatcher.rb', line 34 def ids __map__ &:id end |
#locations ⇒ Object
38 39 40 |
# File 'lib/redis_wmrs/dispatcher.rb', line 38 def locations __map__ &:location end |
#logger=(v) ⇒ Object
46 47 48 |
# File 'lib/redis_wmrs/dispatcher.rb', line 46 def logger=(v) __both__{|c| c.logger = v}; return v end |
#reconnect ⇒ Object
52 |
# File 'lib/redis_wmrs/dispatcher.rb', line 52 def reconnect ; __both__{|c| c.reconnect }; return self; end |