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

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)


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

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)


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

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

.flushObject

Delete all cache entries for this model

Raises:

  • (::Exception)


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

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)


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

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)


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

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