commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl ...@apache.org>
Subject Re: [JCS] Dynamic Cache Expiration on get
Date Fri, 23 Jan 2015 07:21:57 GMT
Hi Jan,

On 16.01.15 17:12, Jan Swaelens wrote:
> Hello,
> 
> I have a region set up to expire its data lets say after 60 seconds.
> There's also a shrink thread running every 100 seconds.
> 
> We add an event handler when storing certain items, in this handler we
> implement some logic to re-insert the expired item on the same key.
> 
> The problem is, when an item expires 'on get' the expiry handler fires
> async and we can't get the updated value in the requesting thread.
> 
> Is it possible to act before the item is actually removed to take the
> keep/toss away call instead of re-inserting it? Any other suggestions for
> solving this pattern?

I understand you want to update your items when they expire, right? This
is normally done in the requesting thread, when the cache returns null
for the requested key. In my experience, this absolutely makes sense
because you will have connections, access rights and stuff available
there. This is usually not the case in a background thread.

That said, I'd like to add that you may add your own implementation of a
memory cache with the desired expiry behavior. See the way the key lists
are handled in LRUMemoryCache and MRUMemoryCache.

Bye, Thomas.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message