Module | Sequel::IndexCaching |
In: |
lib/sequel/extensions/index_caching.rb
|
Set index cache to the empty hash.
# File lib/sequel/extensions/index_caching.rb, line 53 53: def self.extended(db) 54: db.instance_variable_set(:@indexes, {}) 55: end
Dump the index cache to the filename given in Marshal format.
# File lib/sequel/extensions/index_caching.rb, line 65 65: def dump_index_cache(file) 66: File.open(file, 'wb'){|f| f.write(Marshal.dump(@indexes))} 67: nil 68: end
Dump the index cache to the filename given unless the file already exists.
# File lib/sequel/extensions/index_caching.rb, line 72 72: def dump_index_cache?(file) 73: dump_index_cache(file) unless File.exist?(file) 74: end
If no options are provided and there is cached index information for the table, return the cached information instead of querying the database.
# File lib/sequel/extensions/index_caching.rb, line 92 92: def indexes(table, opts=OPTS) 93: return super unless opts.empty? 94: 95: quoted_name = literal(table) 96: if v = Sequel.synchronize{@indexes[quoted_name]} 97: return v 98: end 99: 100: result = super 101: Sequel.synchronize{@indexes[quoted_name] = result} 102: result 103: end
Replace the index cache with the data from the given file, which should be in Marshal format.
# File lib/sequel/extensions/index_caching.rb, line 78 78: def load_index_cache(file) 79: @indexes = Marshal.load(File.read(file)) 80: nil 81: end
Replace the index cache with the data from the given file if the file exists.
# File lib/sequel/extensions/index_caching.rb, line 85 85: def load_index_cache?(file) 86: load_index_cache(file) if File.exist?(file) 87: end