Module: RedisCacheable::Connectable::ClassMethods
- Defined in:
- lib/redis_cacheable/connectable.rb
Instance Method Summary collapse
Instance Method Details
#redis(&blk) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/redis_cacheable/connectable.rb', line 21 def redis(&blk) raise ArgumentError.new("Need block") unless blk connection = __ensure_redis_connection__ case connection when ConnectionPool connection.with do |conn| blk.call(__wrap_namespace__(conn)) end when Redis blk.call(__wrap_namespace__(connection)) else raise "Not redis connection" end end |
#redis_namespace ⇒ Object
14 15 16 17 18 19 |
# File 'lib/redis_cacheable/connectable.rb', line 14 def redis_namespace config = RedisCacheable::Configuration.config namespace = [to_s.underscore] namespace.unshift config.namespace_prefix if config.namespace_prefix namespace.join("_") end |