75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/itrigga/cache/cache.rb', line 75
def with_cache(opts = {}, &block)
require_param(opts, :key)
unless caching_enabled?(opts)
cache_log "Cache not enabled!", opts
return block.call
end
value = get_from_cache(opts[:key], opts)
unless value
cache_log "Key '#{opts[:key]}' missing! Calling block and setting in cache", opts
value = block.call
set_to_cache(opts.delete(:key), value, opts) rescue value else
cache_log "Key '#{opts[:key]}' found in cache!", opts
end
value
end
|