Module: RedisCacheable::ClassMethods
- Defined in:
- lib/redis_cacheable.rb
Instance Method Summary collapse
-
#__redis_cache_attrs__ ⇒ Object
for internal use.
-
#__redis_cache_key__ ⇒ Object
for internal use.
- #find_from_redis(key) ⇒ Object
- #redis_attrs(*attributes) ⇒ Object
- #redis_key(key) ⇒ Object
Instance Method Details
#__redis_cache_attrs__ ⇒ Object
for internal use
43 44 45 |
# File 'lib/redis_cacheable.rb', line 43 def __redis_cache_attrs__ @__redis_cache_attrs__ || [] end |
#__redis_cache_key__ ⇒ Object
for internal use
37 38 39 |
# File 'lib/redis_cacheable.rb', line 37 def __redis_cache_key__ @__redis_cache_key__ || :id end |
#find_from_redis(key) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/redis_cacheable.rb', line 26 def find_from_redis(key) redis do |conn| json = conn.get(key) return nil unless json MultiJson.load(json) end end |
#redis_attrs(*attributes) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/redis_cacheable.rb', line 18 def redis_attrs(*attributes) if attributes.first.is_a?(Proc) @__redis_cache_attrs__ = attributes.first else @__redis_cache_attrs__ = attributes.flatten end end |
#redis_key(key) ⇒ Object
14 15 16 |
# File 'lib/redis_cacheable.rb', line 14 def redis_key(key) @__redis_cache_key__ = key end |