module Sequel::SchemaCaching
Public Instance Methods
Source
# File lib/sequel/extensions/schema_caching.rb 53 def dump_schema_cache(file) 54 sch = dumpable_schema_cache 55 File.open(file, 'wb'){|f| f.write(Marshal.dump(sch))} 56 nil 57 end
Dump the cached schema to the filename given in Marshal format.
Source
# File lib/sequel/extensions/schema_caching.rb 61 def dump_schema_cache?(file) 62 dump_schema_cache(file) unless File.exist?(file) 63 end
Dump the cached schema to the filename given unless the file already exists.
Source
# File lib/sequel/extensions/schema_caching.rb 67 def load_schema_cache(file) 68 @schemas = load_schema_cache_file(file) 69 @schemas.each_value{|v| schema_post_process(v)} 70 nil 71 end
Replace the schema cache with the data from the given file, which should be in Marshal format.
Source
# File lib/sequel/extensions/schema_caching.rb 75 def load_schema_cache?(file) 76 load_schema_cache(file) if File.exist?(file) 77 end
Replace the schema cache with the data from the given file if the file exists.
Private Instance Methods
Source
# File lib/sequel/extensions/schema_caching.rb 87 def dumpable_schema_cache 88 sch = {} 89 90 @schemas.sort.each do |k,v| 91 sch[k] = v.map do |c, h| 92 h = Hash[h] 93 h.delete(:callable_default) 94 [c, h] 95 end 96 end 97 98 sch 99 end
A dumpable version of the schema cache.
Source
# File lib/sequel/extensions/schema_caching.rb 82 def load_schema_cache_file(file) 83 Marshal.load(File.read(file)) 84 end
Return the deserialized schema cache file.