Set index cache to the empty hash.
# File lib/sequel/extensions/index_caching.rb, line 53 def self.extended(db) db.instance_variable_set(:@indexes, {}) end
Dump the index cache to the filename given in Marshal format.
# File lib/sequel/extensions/index_caching.rb, line 65 def dump_index_cache(file) File.open(file, 'wb'){|f| f.write(Marshal.dump(@indexes))} nil end
Dump the index cache to the filename given unless the file already exists.
# File lib/sequel/extensions/index_caching.rb, line 72 def dump_index_cache?(file) dump_index_cache(file) unless File.exist?(file) 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 def indexes(table, opts=OPTS) return super unless opts.empty? quoted_name = literal(table) if v = Sequel.synchronize{@indexes[quoted_name]} return v end result = super Sequel.synchronize{@indexes[quoted_name] = result} result 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 def load_index_cache(file) @indexes = Marshal.load(File.read(file)) nil 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 def load_index_cache?(file) load_index_cache(file) if File.exist?(file) end
Remove the index cache for the given schema name
# File lib/sequel/extensions/index_caching.rb, line 58 def remove_cached_schema(table) k = quote_schema_table(table) Sequel.synchronize{@indexes.delete(k)} super end