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, line 27 def dump_static_cache_cache static_cache_cache = {} @static_cache_cache.sort.each do |k, v| static_cache_cache[k] = v end File.open(@static_cache_cache_file, 'wb'){|f| f.write(Marshal.dump(static_cache_cache))} nil 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, line 43 def load_static_cache_rows if rows = Sequel.synchronize{@static_cache_cache[name]} rows.map{|row| call(row)}.freeze else rows = dataset.all.freeze raw_rows = rows.map(&:values) Sequel.synchronize{@static_cache_cache[name] = raw_rows} rows end end