Module: RedisCacheable
- Extended by:
- ActiveSupport::Concern
- Includes:
- Connectable
- Included in:
- ActiveRecord
- Defined in:
- lib/redis_cacheable.rb,
lib/redis_cacheable/version.rb,
lib/redis_cacheable/connectable.rb,
lib/redis_cacheable/active_record.rb,
lib/redis_cacheable/configuration.rb
Overview
Specialized for ActiveRecord
Defined Under Namespace
Modules: ActiveRecord, ClassMethods, Connectable
Classes: Configuration
Constant Summary
collapse
- VERSION =
"0.3.0"
Instance Method Summary
collapse
#redis
Instance Method Details
#cache_to_redis(expire: nil) ⇒ Object
89
90
91
92
93
94
95
96
97
|
# File 'lib/redis_cacheable.rb', line 89
def cache_to_redis(expire: nil)
redis do |conn|
if expire
conn.setex(redis_cache_key, expire, MultiJson.dump(redis_cache_data))
else
conn.set(redis_cache_key, MultiJson.dump(redis_cache_data))
end
end
end
|
#del_from_redis ⇒ Object
99
100
101
102
103
|
# File 'lib/redis_cacheable.rb', line 99
def del_from_redis
redis do |conn|
conn.del(redis_cache_key)
end
end
|
#expire_redis(sec) ⇒ Object
105
106
107
108
109
|
# File 'lib/redis_cacheable.rb', line 105
def expire_redis(sec)
redis do |conn|
conn.expire(redis_cache_key, sec)
end
end
|
#expireat_redis(unix_time) ⇒ Object
111
112
113
114
115
|
# File 'lib/redis_cacheable.rb', line 111
def expireat_redis(unix_time)
redis do |conn|
conn.expireat(redis_cache_key, unix_time)
end
end
|
#ttl_redis ⇒ Object
117
118
119
120
121
|
# File 'lib/redis_cacheable.rb', line 117
def ttl_redis
redis do |conn|
conn.ttl(redis_cache_key)
end
end
|