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 indexes = {} 60 @indexes.sort.each do |k, v| 61 indexes[k] = v 62 end 63 File.open(file, 'wb'){|f| f.write(Marshal.dump(indexes))} 64 nil 65 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 69 def dump_index_cache?(file) 70 dump_index_cache(file) unless File.exist?(file) 71 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 89 def indexes(table, opts=OPTS) 90 return super unless opts.empty? 91 92 quoted_name = literal(table) 93 if v = Sequel.synchronize{@indexes[quoted_name]} 94 return v 95 end 96 97 result = super 98 Sequel.synchronize{@indexes[quoted_name] = result} 99 result 100 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 75 def load_index_cache(file) 76 @indexes = Marshal.load(File.read(file)) 77 nil 78 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 82 def load_index_cache?(file) 83 load_index_cache(file) if File.exist?(file) 84 end