module Sequel::Plugins::StaticCacheCache

  1. lib/sequel/plugins/static_cache_cache.rb

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"

Methods

Public Class

  1. configure

Public Class methods

configure(model, file)
[show source]
   # File lib/sequel/plugins/static_cache_cache.rb
21 def self.configure(model, file)
22   model.instance_variable_set(:@static_cache_cache_file, file)
23   model.instance_variable_set(:@static_cache_cache, File.exist?(file) ? Marshal.load(File.read(file)) : {})
24 end