lib/openwfe/expool/expstorage.rb in openwferu-0.9.5 vs lib/openwfe/expool/expstorage.rb in openwferu-0.9.6
- old
+ new
@@ -56,20 +56,29 @@
# "expressionStorage.1"
#
class CacheExpressionStorage
include ServiceMixin, OwfeServiceLocator
+ #
+ # under 20 stored expressions, the unit tests for the
+ # CachedFilePersistedEngine do fail because the persistent storage
+ # behind the cache hasn't the time to flush its work queue.
+ # a min size limit has been set to 77.
+ #
+ MIN_SIZE = 77
+
DEFAULT_SIZE = 5000
def initialize (service_name, application_context)
super()
service_init(service_name, application_context)
size = @application_context[:expression_cache_size]
size = DEFAULT_SIZE unless size
+ size = MIN_SIZE unless size > MIN_SIZE
linfo { "new() size is #{size}" }
@cache = LruHash.new(size)
@@ -98,11 +107,14 @@
ldebug { "[] (reload) for #{fei.to_debug_s}" }
fe = get_real_storage[fei]
- return nil unless fe
+ unless fe
+ #ldebug { "[] (reload) miss for #{fei.to_debug_s}" }
+ return nil
+ end
@cache[fei] = fe
return fe
end
@@ -135,21 +147,39 @@
get_real_storage.each_of_kind(kind, &block)
end
def each (&block)
- @cache.each do |k, v|
- block.call(k, v)
- end
+ #@cache.each do |k, v|
+ # block.call(k, v)
+ #end
+ @cache.each(&block)
end
+ #
+ # This each() just delegates to the real storage each() method.
+ #
+ def real_each (&block)
+ #@cache.each do |k, v|
+ # block.call(k, v)
+ #end
+ get_real_storage.each(&block)
+ end
+
+ #
+ # Displays a human-friendly view on this storage
+ #
def to_s
expstorage_to_s(self)
end
protected
+ #
+ # Returns the "real storage" i.e. the storage that does the real
+ # persistence behind this "cache storage".
+ #
def get_real_storage
return @real_storage if @real_storage
@real_storage =
@@ -195,9 +225,11 @@
end
def to_s
expstorage_to_s(self)
end
+
+ alias :real_each :each
end
#
# a small help method for expression storages...