| Class | OpenWFE::CacheExpressionStorage |
| In: |
lib/openwfe/expool/expstorage.rb
|
| Parent: | Object |
This cache uses a LruHash (Least Recently Used) to store expressions. If an expression is not cached, the ‘real storage’ is consulted. The real storage is supposed to be the service named "expressionStorage.1"
| MIN_SIZE | = | 77 | 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. | |
| DEFAULT_SIZE | = | 5000 |
# File lib/openwfe/expool/expstorage.rb, line 192
192: def initialize (service_name, application_context)
193:
194: super()
195:
196: service_init(service_name, application_context)
197:
198: size = @application_context[:expression_cache_size] || DEFAULT_SIZE
199: size = MIN_SIZE unless size > MIN_SIZE
200:
201: linfo { "new() size is #{size}" }
202:
203: @cache = LruHash.new(size)
204:
205: @real_storage = nil
206:
207: observe_expool
208: end
# File lib/openwfe/expool/expstorage.rb, line 210
210: def [] (fei)
211:
212: #ldebug { "[] size is #{@cache.size}" }
213: #ldebug { "[] (sz #{@cache.size}) for #{fei.to_debug_s}" }
214:
215: fe = @cache[fei.hash]
216: return fe if fe
217:
218: #ldebug { "[] (reload) for #{fei.to_debug_s}" }
219:
220: fe = get_real_storage[fei]
221:
222: unless fe
223: #ldebug { "[] (reload) miss for #{fei.to_debug_s}" }
224: return nil
225: end
226:
227: @cache[fei.hash] = fe
228:
229: fe
230: end
# File lib/openwfe/expool/expstorage.rb, line 232
232: def []= (fei, fe)
233:
234: ldebug { "[]= caching #{fei}" }
235:
236: @cache[fei.hash] = fe
237: end
# File lib/openwfe/expool/expstorage.rb, line 239
239: def delete (fei)
240:
241: @cache.delete fei.hash
242: end
Attempts at fetching the root expression of a given process instance.
# File lib/openwfe/expool/expstorage.rb, line 271
271: def fetch_root (wfid)
272:
273: #
274: # at first, look in the cache
275:
276: @cache.each do |hashed_fei, fexp|
277:
278: return fexp \
279: if fexp.fei.wfid == wfid and fexp.is_a?(DefineExpression)
280: end
281:
282: get_real_storage.fetch_root wfid
283: end
This implementations of find_expressions() immediately passes the call to the underlying real storage.
# File lib/openwfe/expool/expstorage.rb, line 262
262: def find_expressions (options={})
263:
264: get_real_storage.find_expressions options
265: end
Returns the "real storage" i.e. the storage that does the real persistence behind this "cache storage".
# File lib/openwfe/expool/expstorage.rb, line 291
291: def get_real_storage
292:
293: #return @real_storage if @real_storage
294: #@real_storage =
295: # @application_context[S_EXPRESSION_STORAGE + ".1"]
296: #@real_storage
297:
298: @application_context["expressionStorage.1"]
299: end