Class: Lore::Cache::Cached_Entities

Inherits:
Object
  • Object
show all
Defined in:
lib/lore/cache/cached_entities.rb

Constant Summary collapse

@@logger =
Lore.logger
@@mmap_cache =
Hash.new
@@file_index =
Hash.new

Class Method Summary collapse

Class Method Details

.[](query_string) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/lore/cache/cached_entities.rb', line 43

def self.[](query_string)
  if $cb__use_pstore_cache then
    return read_pstore_cache(query_string)
  else 
    return read_mmap_cache(query_string)
  end
end

.[]=(query_string, result) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/lore/cache/cached_entities.rb', line 25

def self.[]=(query_string, result)
  if $cb__use_pstore_cache then
    create_pstore_cache(query_string, result) 
  else
    create_mmap_cache(query_string, result) 
  end
end

.create(accessor, query_string, result) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/lore/cache/cached_entities.rb', line 33

def self.create(accessor, query_string, result)
  if $cb__use_pstore_cache then
    file = create_pstore_cache(query_string, result) 
  else
    file = create_mmap_cache(query_string, result) 
  end
  @@file_index[accessor.table_name] = Array.new unless @@file_index[accessor.table_name]
  @@file_index[accessor.table_name] << file
end

.flush(type) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/lore/cache/cached_entities.rb', line 15

def self.flush(type)
  index = type.table_name
  return if (!Lore.cache_entities() || @@file_index[index].nil?)
  @@file_index[index].each { |cache_file|
    @@logger.debug { 'Clearing cache file ' << cache_file }
    File.unlink(cache_file)
  }
  @@file_index.delete(type.table_name)
end

.include?(query_string) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/lore/cache/cached_entities.rb', line 51

def self.include?(query_string)
  FileTest.exist?(storefile_of(query_string))
end