orm - Is it possible to change flushInterval value in myBatis's own cache implementation dynamically -
there 2 scenarios want flush interval 300000 (5 mins) , in cases dont want flush interval @ i.e. want cache constant throughout session i.e. want flush disabled , if release freeze should again operate after every 5 mins.
<cache eviction="fifo" flushinterval="300000" size="512" readonly="true"/> <select id="getstoreidandeqid" resulttype="string" flushcache="false" usecache="true"> select count(author) blog </select>
technology using mybatis , spring.
so, have debugged little , unfortunately, answer question is... "kind of"...
when use cache configuration, following cache structure (by configuration.mappedstatement( id ).cache
):
a synchronizedcache
delegates caching logingcache
delegates caching scheduledcache
delegates caching fifocache
delegates caching perpetualcache
. every 1 of these delegates little bit of work (logging, etc.) , delegates rest.
unfortunately, there seems no "normal" way delegate of synchronizedcache
, class offers no way modify settings of underlying cache
objects. of course use reflection them, that's not idea. so, don't see way default caches.
which leads "kind of" answer... can write own cache
implementation, example mycacheimpl
, work , set via...
<cache type="com.example.mycacheimpl"/>
unfortunately, wrapped in loggingcache (that delegates it) and, guessed right, loggingcache doesn't offer way delegate. have workaround there, example registering caches in static hashmap or this. of course, can open whole can of bugs, tread carefully. when so, can access caches directly , call behaviour altering methods want.
Comments
Post a Comment