Module: Catche::Tag
Defined Under Namespace
Classes: Collect
Constant Summary collapse
- KEY =
'catche'
- DIVIDER =
'_'
Instance Method Summary collapse
- #expire!(*tags) ⇒ Object
- #join(*tags) ⇒ Object
-
#tag_page!(page, *tags) ⇒ Object
Tags a page cache.
-
#tag_type!(scope, value, *tags) ⇒ Object
Dynamic method for tagging a type of stored cache.
-
#tag_view!(view, *tags) ⇒ Object
(also: #tag_fragment!)
Tags a view.
Instance Method Details
#expire!(*tags) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/catche/tag.rb', line 53 def expire!(*) .each do |tag| Catche::Expire.expire! fetch_tag(tag) Catche.adapter.delete stored_key(:tags, tag) end end |
#join(*tags) ⇒ Object
11 12 13 |
# File 'lib/catche/tag.rb', line 11 def join(*) .flatten.compact.uniq.join(DIVIDER) end |
#tag_page!(page, *tags) ⇒ Object
Tags a page cache
22 23 24 |
# File 'lib/catche/tag.rb', line 22 def tag_page!(page, *) tag_type! :pages, page, * end |
#tag_type!(scope, value, *tags) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/catche/tag.rb', line 29 def tag_type!(scope, value, *) .each do |tag| data = fetch_tag(tag) # Set up key names tag_key = stored_key(:tags, tag) type_key = stored_key(scope, value) # Current tags = fetch_type(scope, value) # Append new value to scoped data data[scope] ||= [] data[scope] << value tag_data = data # Append new tag key type_data = << tag_key Catche.adapter.write(tag_key, tag_data) Catche.adapter.write(type_key, type_data) end end |
#tag_view!(view, *tags) ⇒ Object Also known as: tag_fragment!
Tags a view
16 17 18 |
# File 'lib/catche/tag.rb', line 16 def tag_view!(view, *) tag_type! :views, view, * end |