module Sequel::Plugins::StaticCacheCache::ClassMethods
Public Instance Methods
Source
# File lib/sequel/plugins/static_cache_cache.rb 28 def dump_static_cache_cache 29 static_cache_cache = {} 30 @static_cache_cache.sort.each do |k, v| 31 static_cache_cache[k] = v 32 end 33 File.open(@static_cache_cache_file, 'wb'){|f| f.write(Marshal.dump(static_cache_cache))} 34 nil 35 end
Dump the in-memory cached rows to the cache file.
Private Instance Methods
Source
# File lib/sequel/plugins/static_cache_cache.rb 44 def load_static_cache_rows 45 if rows = Sequel.synchronize{@static_cache_cache[name]} 46 rows.map{|row| call(row)}.freeze 47 else 48 rows = dataset.all.freeze 49 raw_rows = rows.map(&:values) 50 Sequel.synchronize{@static_cache_cache[name] = raw_rows} 51 rows 52 end 53 end
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.