Print Page | Close Window

Expire Query Cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1680
Printed Date: 02-Apr-2025 at 1:50am


Topic: Expire Query Cache
Posted By: kpinniger
Subject: Expire Query Cache
Date Posted: 10-Mar-2010 at 6:20pm

Is there a setting on the EntityManager to remove an Entity from the cache after x amount of time?  Basically we know that the data might change during the day and we would like the cache to get invalidated after say 30 minutes. 

Thanks,
Kurt Pinniger
CDC Software



Replies:
Posted By: tooms
Date Posted: 17-May-2011 at 3:06pm
I too would like to know if this is possible.
 
Our applications database can become quite large and on occassion a query may return 100k+ records which has a detremental affect on the system (performance and memory use) and we'd like a way to expire this cache.
 
Additionaly, is there a way to easily the number of entities returned and then intelligently decide if they should be cahced or not? Perhaps off the back of a dialogue box?
 
I'd also like to know how to appropriately clear the cache, is it enough to say QueryCache.Clear() and/or DataSet/Clear() .. ? I notice when I do this, no memory is freed up from the application.
 
Cheers,
Paul Twomey
MEX


Posted By: robertg
Date Posted: 23-May-2011 at 5:17pm
KPinniger, there is no automatic way to do that, though you could certainly add a timestamp field to the entity, then before you use it, do a query to find and remove anything older than the desired period of time. (Alternately, you can just keep track of when your cache was generated, and replace the entire thing when the amount of time in question has passed.)
 
Paul, you may want to look into using a projection in order to limit the amount of data being returned to your client, so you are only transmitting/caching the entities that you're actually going to use. We have an article in the DRC which talks about doing this, http://drc.ideablade.com/xwiki/bin/view/Documentation/query-anonymous-projections - http://drc.ideablade.com/xwiki/bin/view/Documentation/query-anonymous-projections .
 
Also, as to the Clear() functions; doing so should mark that memory as available for reclamation, when .NET does its garbage collection. If you use RemoveEntities() instead, it does so right away.



Print Page | Close Window