module Sequel::Plugins::StaticCacheCache::ClassMethods

Public Instance Methods

dump_static_cache_cache() click to toggle source

Dump the in-memory cached rows to the cache file.

   # File lib/sequel/plugins/static_cache_cache.rb
28 def dump_static_cache_cache
29   File.open(@static_cache_cache_file, 'wb'){|f| f.write(Marshal.dump(@static_cache_cache))}
30   nil
31 end

Private Instance Methods

load_static_cache_rows() click to toggle source

Load the rows for the model from the cache if available. If not available, load the rows from the database, and then update the cache with the raw rows.

   # File lib/sequel/plugins/static_cache_cache.rb
40 def load_static_cache_rows
41   if rows = Sequel.synchronize{@static_cache_cache[name]}
42     rows.map{|row| call(row)}.freeze
43   else
44     rows = dataset.all.freeze
45     raw_rows = rows.map(&:values)
46     Sequel.synchronize{@static_cache_cache[name] = raw_rows}
47     rows
48   end
49 end