Module: Bizside::CacheUtil
- Included in:
- CacheUtils
- Defined in:
- lib/bizside/cache_util.rb
Instance Method Summary collapse
- #cache ⇒ Object
- #clear(options = nil) ⇒ Object
- #delete(key) ⇒ Object
- #delete_matched(matcher) ⇒ Object
- #fetch(key, options = {}) ⇒ Object
Instance Method Details
#cache ⇒ Object
32 33 34 |
# File 'lib/bizside/cache_util.rb', line 32 def cache raise 'サブクラスで実装' end |
#clear(options = nil) ⇒ Object
27 28 29 30 |
# File 'lib/bizside/cache_util.rb', line 27 def clear( = nil) output_log "CLEAR ALL CACHE" cache.clear() end |
#delete(key) ⇒ Object
17 18 19 20 |
# File 'lib/bizside/cache_util.rb', line 17 def delete(key) output_log "CLEAR CACHE: #{key}" cache.delete(key) end |
#delete_matched(matcher) ⇒ Object
22 23 24 25 |
# File 'lib/bizside/cache_util.rb', line 22 def delete_matched(matcher) output_log "CLEAR CACHE: #{matcher}" cache.delete_matched(matcher) end |
#fetch(key, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bizside/cache_util.rb', line 4 def fetch(key, = {}) if block_given? action = cache.exist?(key) ? 'READ' : 'WRITE' output_log "#{action} CACHE: #{key}" cache.fetch(key, ) do yield end else output_log "READ CACHE: #{key}" cache.fetch(key, ) end end |