Sha256: 5c50883c9c25a97fcf1f38b63892b3e34e86285334b279de9809ab7b8a04933e
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
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, :options def initialize(component, options={}) @component = component @options = options 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
5 entries across 5 versions & 1 rubygems