Class: Lore::Cache::Abstract_Entity_Cache

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

Overview

When implementing your own entity cache, derive from and implement Abstract_Entity_Cache. Expected class methods are:

- flush
- read(query_string)
- create(model_klass, query_string, result)
- include?(query_string)
- delete(cache_index)
  cache_index being an MD5 sum of the query_string that 
  generated the cache entry. 
  In case you want cache indices other than MD5 sums, 
  define class method 
  index_for(query_string)

Every model may use a different caching implementation. To enable a specific caching implenentation for a model, use:

class Your_Model < Lore::Model
  ...
  use_cache_impl The_Cache_Implementation_Klass
  ...
end

Direct Known Subclasses

Mmap_Entity_Cache

Class Method Summary collapse

Class Method Details

.create(accessor, query_object, result) ⇒ Object

Create cache entry for a specific query_string on a model. Expects result from given query string as it has to be returned when calling Cache_Implementation.read(query_string)

Raises:

  • (::Exception)


48
49
50
# File 'lib/lore/cache/abstract_entity_cache.rb', line 48

def self.create(accessor, query_object, result)
  raise ::Exception.new('Not implemented')
end

.delete(index) ⇒ Object

Delete a specific cache entry, parameter index being primary key (e.g. a hash value) in cache generated from a query.

Raises:

  • (::Exception)


60
61
62
# File 'lib/lore/cache/abstract_entity_cache.rb', line 60

def self.delete(index)
  raise ::Exception.new('Not implemented')
end

.flushObject

Delete all cache entries for this model

Raises:

  • (::Exception)


35
36
37
# File 'lib/lore/cache/abstract_entity_cache.rb', line 35

def self.flush
  raise ::Exception.new('Not implemented')
end

.include?(accessor, query_string) ⇒ Boolean

Whether there is a cache entry for a query or not.

Returns:

  • (Boolean)

Raises:

  • (::Exception)


53
54
55
# File 'lib/lore/cache/abstract_entity_cache.rb', line 53

def self.include?(accessor, query_string)
  raise ::Exception.new('Not implemented')
end

.read(accessor, query_string) ⇒ Object

Read cached result for a specific query string. Returns array of model instances.

Raises:

  • (::Exception)


41
42
43
# File 'lib/lore/cache/abstract_entity_cache.rb', line 41

def self.read(accessor, query_string)
  raise ::Exception.new('Not implemented')
end