Sha256: b027526dc3d2d8c520738346a8408026e5efc3fa1fd0278ea0ae7f757e21c3d4
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'infopark_component_cache/cache_storage' module InfoparkComponentCache # @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. class ConsistencyGuard attr_reader :component def initialize(component) @component = component end # @return [CacheStorage] instance of CacheStorage def cache CacheStorage.instance end # @abstract # This method returns true if the consistenty guarded by this class # is fulfilled and false otherwise. def consistent? raise TypeError, "Abstract method consistent? called" end # @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. def guard! raise TypeError, "Abstract method guard! called" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
infopark_component_cache-1.1.0 | lib/infopark_component_cache/consistency_guard.rb |
infopark_component_cache-1.0.0 | lib/infopark_component_cache/consistency_guard.rb |