Module: Memorize::Keys
- Defined in:
- lib/memorize/keys.rb
Overview
Memorize padroniza e mantém as entradas associadas a um “grupo” e “key”.
Ao extender o Memorize::Keys, os seguintes m
Instance Method Summary collapse
- #cache_entries(group, options = {}) ⇒ Object
- #cache_expires(group, options = {}) ⇒ Object
- #cache_key(group, options = {}) ⇒ Object
Instance Method Details
#cache_entries(group, options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/memorize/keys.rb', line 21 def cache_entries(group, = {}) group_key = build_group_key(group, .delete(:key)) Memorize.cache_store.read(group_key) || [] end |
#cache_expires(group, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/memorize/keys.rb', line 26 def cache_expires(group, = {}) group_key = build_group_key(group, .delete(:key)) (Memorize.cache_store.read(group_key) || []).each { |key| Memorize.cache_store.delete(key) } Memorize.cache_store.delete(group_key) end |
#cache_key(group, options = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/memorize/keys.rb', line 13 def cache_key(group, = {}) param_key = .delete(:key) group_key = build_group_key(group, param_key) cache_key = build_cache_key(group, param_key, .delete(:params)) update_cache_entry(group_key, cache_key) cache_key end |