lib/redis_failover/util.rb in redis_failover-0.8.9 vs lib/redis_failover/util.rb in redis_failover-0.9.0
- old
+ new
@@ -3,17 +3,63 @@
module RedisFailover
# Common utiilty methods and constants.
module Util
extend self
+ # Redis read operations that are automatically dispatched to slaves. Any
+ # operation not listed here will be dispatched to the master.
+ REDIS_READ_OPS = Set[
+ :echo,
+ :exists,
+ :get,
+ :getbit,
+ :getrange,
+ :hexists,
+ :hget,
+ :hgetall,
+ :hkeys,
+ :hlen,
+ :hmget,
+ :hvals,
+ :keys,
+ :lindex,
+ :llen,
+ :lrange,
+ :mapped_hmget,
+ :mapped_mget,
+ :mget,
+ :scard,
+ :sdiff,
+ :sinter,
+ :sismember,
+ :smembers,
+ :srandmember,
+ :strlen,
+ :sunion,
+ :type,
+ :zcard,
+ :zcount,
+ :zrange,
+ :zrangebyscore,
+ :zrank,
+ :zrevrange,
+ :zrevrangebyscore,
+ :zrevrank,
+ :zscore
+ ].freeze
+
+ # Unsupported Redis operations. These don't make sense in a client
+ # that abstracts the master/slave servers.
+ UNSUPPORTED_OPS = Set[:select, :dbsize].freeze
+
# Default node in ZK that contains the current list of available redis nodes.
DEFAULT_ZNODE_PATH = '/redis_failover_nodes'.freeze
# Connectivity errors that the redis (<3.x) client raises.
REDIS_ERRORS = Errno.constants.map { |c| Errno.const_get(c) }
# Connectivity errors that the redis (>3.x) client raises.
- REDIS_ERRORS << Redis::BaseError if Redis.const_defined?("BaseError")
+ REDIS_ERRORS << Redis::BaseError if Redis.const_defined?('BaseError')
REDIS_ERRORS.freeze
# Full set of errors related to connectivity.
CONNECTIVITY_ERRORS = [
RedisFailover::Error,