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"

Methods

[]   []=   clear   delete   fetch_root   find_expressions   get_real_storage   length   new   purge   size  

Included Modules

ServiceMixin OwfeServiceLocator ExpressionStorageBase

Constants

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

Public Class methods

[Source]

     # 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

Public Instance methods

[Source]

     # 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

[Source]

     # 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

[Source]

     # File lib/openwfe/expool/expstorage.rb, line 251
251:         def clear
252: 
253:             @cache.clear
254:         end

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # File lib/openwfe/expool/expstorage.rb, line 262
262:         def find_expressions (options={})
263: 
264:             get_real_storage.find_expressions options
265:         end

[Source]

     # File lib/openwfe/expool/expstorage.rb, line 244
244:         def length
245: 
246:             @cache.length
247:         end
purge()

Alias for clear

size()

Alias for length

Protected Instance methods

Returns the "real storage" i.e. the storage that does the real persistence behind this "cache storage".

[Source]

     # 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

[Validate]