Module: QPush::Base::RedisHelper::ClassMethods
- Defined in:
- lib/qpush/base/redis.rb
Instance Method Summary collapse
- #build_keys(namespace, priorities) ⇒ Object
- #build_pool(pool, url) ⇒ Object
- #redis ⇒ Object
- #redis_pool ⇒ Object
Instance Method Details
#build_keys(namespace, priorities) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/qpush/base/redis.rb', line 35 def build_keys(namespace, priorities) name = "#{QPush::Base::KEY}:#{namespace}" keys = Hash[QPush::Base::SUB_KEYS.collect { |key| [key, "#{name}:#{key}"] }] keys[:perform_list] = (1..priorities).collect { |num| "#{keys[:perform]}:#{num}" } keys end |
#build_pool(pool, url) ⇒ Object
29 30 31 32 33 |
# File 'lib/qpush/base/redis.rb', line 29 def build_pool(pool, url) ConnectionPool.new(size: pool) do Redis.new(url: url) end end |
#redis ⇒ Object
19 20 21 22 23 |
# File 'lib/qpush/base/redis.rb', line 19 def redis redis_pool.with do |conn| yield conn end end |
#redis_pool ⇒ Object
25 26 27 |
# File 'lib/qpush/base/redis.rb', line 25 def redis_pool @redis_pool ||= build_pool(config.redis_pool, config.redis_url) end |