Class: InfoparkComponentCache::ConsistencyGuard Abstract
- Inherits:
-
Object
- Object
- InfoparkComponentCache::ConsistencyGuard
- Defined in:
- lib/infopark_component_cache/consistency_guard.rb
Overview
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.
Direct Known Subclasses
CmsStateGuard, Guards::AlwaysConsistent, Guards::NeverConsistent, Guards::ValuePresent
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#cache ⇒ CacheStorage
Instance of CacheStorage.
-
#consistent? ⇒ Boolean
abstract
This method returns true if the consistenty guarded by this class is fulfilled and false otherwise.
-
#guard! ⇒ Object
abstract
This method is called whenever cache is updated for the component.
-
#initialize(component, options = {}) ⇒ ConsistencyGuard
constructor
A new instance of ConsistencyGuard.
Constructor Details
#initialize(component, options = {}) ⇒ ConsistencyGuard
Returns a new instance of ConsistencyGuard.
18 19 20 21 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 18 def initialize(component, = {}) @component = component @options = end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
16 17 18 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 16 def component @component end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 16 def @options end |
Instance Method Details
#cache ⇒ CacheStorage
Returns instance of CacheStorage.
24 25 26 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 24 def cache CacheStorage.instance end |
#consistent? ⇒ Boolean
This method returns true if the consistenty guarded by this class is fulfilled and false otherwise.
31 32 33 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 31 def consistent? raise TypeError, "Abstract method consistent? called" end |
#guard! ⇒ Object
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.
39 40 41 |
# File 'lib/infopark_component_cache/consistency_guard.rb', line 39 def guard! raise TypeError, "Abstract method guard! called" end |