module Card::Cache::ClassMethods
class methods for Card::Cache
Attributes
counter[RW]
no_renewal[RW]
Public Instance Methods
[](klass)
click to toggle source
create a new cache for the ruby class provided @param klass [Class] @return [{Card::Cache}]
# File lib/card/cache/class_methods.rb, line 14 def [] klass raise "nil klass" if klass.nil? cache_by_class[klass] ||= new class: klass, store: (shared_cache || nil) end
cache_by_class()
click to toggle source
# File lib/card/cache/class_methods.rb, line 101 def cache_by_class @cache_by_class ||= {} end
renew()
click to toggle source
clear the temporary caches and ensure we’re using the latest stamp on the shared caches.
# File lib/card/cache/class_methods.rb, line 22 def renew # Cardio.config.cache_log_level = :debug # Cardio.config.view_cache = true # Cardio.config.asset_refresh = :cautious # Cache.reset_all Card::Cache.counter = nil return if no_renewal renew_shared cache_by_class.each_value do |cache| cache.temp.reset cache.shared&.renew end populate_temp_cache end
reset()
click to toggle source
reset standard cached for all classes
# File lib/card/cache/class_methods.rb, line 45 def reset reset_shared reset_temp end
reset_all()
click to toggle source
reset all caches for all classes
# File lib/card/cache/class_methods.rb, line 51 def reset_all reset_shared reset_temp reset_other end
reset_global()
click to toggle source
completely wipe out all caches, often including the Shared
cache of other decks using the same mechanism. Generally prefer {.reset_all} @see .reset_all
# File lib/card/cache/class_methods.rb, line 61 def reset_global cache_by_class.each_value do |cache| cache.temp.reset cache.shared&.annihilate end reset_other end
reset_other()
click to toggle source
reset Codename
cache and delete tmp files (the non-standard caches)
# File lib/card/cache/class_methods.rb, line 84 def reset_other Card::Codename.reset_cache Cardio::Utils.delete_tmp_files! end
reset_temp()
click to toggle source
reset the Temporary
cache for all classes
# File lib/card/cache/class_methods.rb, line 78 def reset_temp cache_by_class.each_value { |cache| cache.temp.reset } end
restore()
click to toggle source
# File lib/card/cache/class_methods.rb, line 89 def restore reset_temp seed_from_stash end
tallies()
click to toggle source
# File lib/card/cache/class_methods.rb, line 111 def tallies "#{tally_total} Cache calls (" + counter.map { |k, v| "#{k}=#{v} " }.join + ")" end
Private Instance Methods
tally_total()
click to toggle source
# File lib/card/cache/class_methods.rb, line 117 def tally_total counter.values.map(&:values).flatten.sum end