class InfoparkComponentCache::ConsistencyGuard

@author Tomasz Przedmojski <tomasz.przedmojski@infopark.de>

@abstract This is abstract base class for any Cache Guards. Any class inheriting ConsistencyGuard should implement consistent? and guard!

Cache Guard is a class that promises some consistency, for example that no changes to the database accured between calls to guard! and consistent?

This consistency is crucial for the function of cache, because inconsistent cache is (automatically) invalidated.

Attributes

component[R]
options[R]

Public Class Methods

new(component, options = {}) click to toggle source
# File lib/infopark_component_cache/consistency_guard.rb, line 18
def initialize(component, options = {})
  @component = component
  @options   = options
end

Public Instance Methods

cache() click to toggle source

@return [CacheStorage] instance of CacheStorage

# File lib/infopark_component_cache/consistency_guard.rb, line 24
def cache
  CacheStorage.instance
end
consistent?() click to toggle source

@abstract This method returns true if the consistenty guarded by this class is fulfilled and false otherwise.

# File lib/infopark_component_cache/consistency_guard.rb, line 31
def consistent?
  raise TypeError, "Abstract method consistent? called"
end
guard!() click to toggle source

@abstract This method is called whenever cache is updated for the component. Any values checked by consistent? can be persisted here. Use #{cache} for persistence but mind the possible inconsistencies.

# File lib/infopark_component_cache/consistency_guard.rb, line 39
def guard!
  raise TypeError, "Abstract method guard! called"
end