Module: TDiary::Cache
- Defined in:
- lib/tdiary/cache/redis.rb
Instance Method Summary collapse
- #clear_cache(target = :all) ⇒ Object
- #restore_cache(prefix) ⇒ Object
- #store_cache(cache, prefix) ⇒ Object
Instance Method Details
#clear_cache(target = :all) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tdiary/cache/redis.rb', line 19 def clear_cache(target = :all) if target == :all delete_data(:all) else ym = target.to_s.scan(/\d{4}\d{2}/)[0] ['latest.rb', 'i.latest.rb', "#{ym}.rb", "i.#{ym}.rb"].each do |key| delete_data(key) end end end |
#restore_cache(prefix) ⇒ Object
7 8 9 10 11 |
# File 'lib/tdiary/cache/redis.rb', line 7 def restore_cache(prefix) if key = cache_key(prefix) restore_data(key) end end |
#store_cache(cache, prefix) ⇒ Object
13 14 15 16 17 |
# File 'lib/tdiary/cache/redis.rb', line 13 def store_cache(cache, prefix) if key = cache_key(prefix) store_data(cache, key) end end |