struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <epr...@ptc.com>
Subject Re: [OT] caching strategy
Date Mon, 23 Jun 2003 16:04:00 GMT
Thanks Jacob, that is very informative.  I will look further into these 
techniques, although you've pretty much explained it.


Erik



Hookom, Jacob wrote:
> LRU - Least Recently Used.  You define your cache size and every time an
> object is created or "grabbed" from the cache, it gets promoted to the top
> of the cache, or you can have its timestamp reset to 'now'.  As objects are
> created, you check to see if the cache is too big, if so, take the oldest or
> the item from the bottom of the stack out of the cache.
> 
> Softly Referenced - Instead of putting the actual object as the value in a
> Hashmap, wrap it in a 'SoftReference' which may loose the object depending
> on how the garbage collector handles things with memory resources.  This
> allows you to have as much as you want for cached objects, but keep in mind,
> if the VM needs more memory, your softly-referenced objects are on the
> chopping block.  Depending on the VM to manage your cache can be a little
> bit more expensive for processing and you will see the GC running a little
> bit more frequently-- the trade off is that you've maximized your memory
> usage and with some VM arguments, you can reduce the GC runs into a
> manageable amount on an enterprise system.
> 
> public Object fetchObject(Object identity)
> {
> 	Object result = null;
> 	SoftReference ref = this.map.get(identity);
> 	if (ref != null)
> 	{
> 		result = ref.get();
> 		if (result == null)
> 		{
> 			ref = null;
> 			this.map.remove(identity);
> 		}
> 	}
> 	return result;
> }
> 
> --------
> Jacob Hookom
> Senior Programmer/Analyst
> McKesson Medical Surgical
> Golden Valley, MN
> 
> -----Original Message-----
> From: Erik Price [mailto:eprice@ptc.com]
> Sent: Friday, June 20, 2003 3:49 PM
> To: Struts Users Mailing List
> Subject: Re: [OT] caching strategy
> 
> 
> 
> 
> Hookom, Jacob wrote:
> 
>>create primary keys for your data, create an identity object to represent
>>legacy data, create a hashmap or cache interface and use either LRU's or
>>Softly referenced caching.  Pretty straight forward.  Logic would be
> 
> "select
> 
>>primary keys + lastModified" if changed or not found, create, else pull
> 
> from
> 
>>cache.
> 
> 
> Okay I understand the first part -- proxy the legacy data entities with 
> Java objects, and use a HashMap-based cache (perhaps using the primary 
> keys as the hash's keys).  But...
> 
> What are LRU's?  Softly referenced caching -- have a particularly good 
> resource on this topic?
> 
> 
> Erik
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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


Mime
View raw message