Methods
Public Class
Public Instance
Public Class methods
extended(db)
Set index cache to the empty hash.
[show source]
# File lib/sequel/extensions/index_caching.rb 53 def self.extended(db) 54 db.instance_variable_set(:@indexes, {}) 55 end
Public Instance methods
dump_index_cache(file)
Dump the index cache to the filename given in Marshal format.
[show source]
# File lib/sequel/extensions/index_caching.rb 58 def dump_index_cache(file) 59 File.open(file, 'wb'){|f| f.write(Marshal.dump(@indexes))} 60 nil 61 end
dump_index_cache?(file)
Dump the index cache to the filename given unless the file already exists.
[show source]
# File lib/sequel/extensions/index_caching.rb 65 def dump_index_cache?(file) 66 dump_index_cache(file) unless File.exist?(file) 67 end
indexes(table, opts=OPTS)
If no options are provided and there is cached index information for the table, return the cached information instead of querying the database.
[show source]
# File lib/sequel/extensions/index_caching.rb 85 def indexes(table, opts=OPTS) 86 return super unless opts.empty? 87 88 quoted_name = literal(table) 89 if v = Sequel.synchronize{@indexes[quoted_name]} 90 return v 91 end 92 93 result = super 94 Sequel.synchronize{@indexes[quoted_name] = result} 95 result 96 end
load_index_cache(file)
Replace the index cache with the data from the given file, which should be in Marshal format.
[show source]
# File lib/sequel/extensions/index_caching.rb 71 def load_index_cache(file) 72 @indexes = Marshal.load(File.read(file)) 73 nil 74 end
load_index_cache?(file)
Replace the index cache with the data from the given file if the file exists.
[show source]
# File lib/sequel/extensions/index_caching.rb 78 def load_index_cache?(file) 79 load_index_cache(file) if File.exist?(file) 80 end