Class: Rails::Cache::Tags::Set
- Inherits:
-
Object
- Object
- Rails::Cache::Tags::Set
- Defined in:
- lib/rails/cache/tags/set.rb
Instance Method Summary collapse
- #check(entry) ⇒ Object
- #current(tag) ⇒ Object
- #expire(tag) ⇒ Object
-
#initialize(store) ⇒ Set
constructor
A new instance of Set.
Constructor Details
#initialize(store) ⇒ Set
Returns a new instance of Set.
11 12 13 14 |
# File 'lib/rails/cache/tags/set.rb', line 11 def initialize(store) @store = store @tags_cache = LocalCache.new end |
Instance Method Details
#check(entry) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails/cache/tags/set.rb', line 30 def check(entry) return entry unless entry.is_a?(Store::Entry) return entry.value if entry..blank? = Tag.build(entry..keys) saved_versions = entry..values.map(&:to_i) saved_versions == current_versions() ? entry.value : nil end |
#current(tag) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rails/cache/tags/set.rb', line 16 def current(tag) key = tag.to_key @tags_cache.fetch(key) do @store.(key) { 1 }.to_i end end |
#expire(tag) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/rails/cache/tags/set.rb', line 23 def expire(tag) version = current(tag) + 1 @store.(tag.to_key, version, :expires_in => nil) version end |