Module: Sequel::Plugins::StaticCacheCache
- Defined in:
- lib/sequel/plugins/static_cache_cache.rb
Overview
The static_cache_cache plugin allows for caching the row content for the current class and subclasses that use the static_cache or subset_static_cache plugins. Using this plugin can avoid the need to query the database every time loading the static_cache plugin into a model (static_cache plugin) or using the cache_subset method (subset_static_cache plugin).
Usage:
# Make all model subclasses that use the static_cache plugin use
# the cached values in the given file
Sequel::Model.plugin :static_cache_cache, "static_cache.cache"
# Make the AlbumType model the cached values in the given file,
# should be loaded before the static_cache plugin
AlbumType.plugin :static_cache_cache, "static_cache.cache"
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.configure(model, file) ⇒ Object
21 22 23 24 |
# File 'lib/sequel/plugins/static_cache_cache.rb', line 21 def self.configure(model, file) model.instance_variable_set(:@static_cache_cache_file, file) model.instance_variable_set(:@static_cache_cache, File.exist?(file) ? Marshal.load(File.read(file)) : {}) end |