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) ⇒ String || Number || Array || Hash
- #redis_attrs(*attributes) ⇒ Object
- #redis_key(key) ⇒ Object
Instance Method Details
#__redis_cache_attrs__ ⇒ Object
for internal use
74 75 76 |
# File 'lib/redis_cacheable.rb', line 74 def __redis_cache_attrs__ @__redis_cache_attrs__ || [] end |
#__redis_cache_key__ ⇒ Object
for internal use
68 69 70 |
# File 'lib/redis_cacheable.rb', line 68 def __redis_cache_key__ @__redis_cache_key__ || :id end |
#find_from_redis(key) ⇒ String || Number || Array || Hash
57 58 59 60 61 62 63 64 |
# File 'lib/redis_cacheable.rb', line 57 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
47 48 49 50 51 52 53 |
# File 'lib/redis_cacheable.rb', line 47 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
38 39 40 |
# File 'lib/redis_cacheable.rb', line 38 def redis_key(key) @__redis_cache_key__ = key end |