caching - Is it ok to simply cache every search using a CachingWrapperFilter? -



caching - Is it ok to simply cache every search using a CachingWrapperFilter? -

using lucene.net 3.0.3 easy wrap every query created in response user's search in cachingwrapperfilter. bad thought because lucene consume more , more memory, or lucene manage memory , release cached items in intelligent way?

should selective in queries wrap in cachingwrapperfilter?

query query = .... querywrapperfilter queryfilter = new querywrapperfilter(query); cachingwrapperfilter cachingfilter = new cachingwrapperfilter(queryfilter); searcher.search(query, cachingfilter, 1); update

the lucene.net implementation of cachingwrapperfilter uses mechanism tied garbage collection. implements weakdictionary class keyed using instances of weakreference class. built in .net class wraps object , provides way check if object has been garbage collected or not. suggests me reply question yes. memory management of lucene cache kept under command because tied runtime garbage collector , cache items maintained long still valid.

a bit more detail...

the keys cache provided indexreader before beingness wrapped in weakreference. indexreader manages objects provides cache keys. when no longer valid disposed , subsequently garbage collected. cache can observe through weakreference , remove item cache.

through weak reference mechanism indexreader , cache can disconnected. indexreader controls validity of cache items disposing key objects, , cache cleans up.

in java lucene, particular cache using weakhashmap means entries cleared automagically 1 time memory pressure level intensifies. if there's counterpart weakhashmap in .net, i'd expect used well.

caching lucene lucene.net

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -