I'd like to propose changes to the caching mechanism in Turbine.


1 - Multiple caches
-------------------
Instead of there being a single global cache service, there
would be a possibility of creating multiple Caches, each with
it's own set of objects in cache.  This would be somewhat 
similar to the way the PoolBrokerService is used.

I would like to create a class org.apache.turbine.tools.Cache 
this class would contain the function clearCache(), but would
rely on outside forces to run it.

The cache service would create these Cache objects as it
received requests to put objects in the cache, storing
the cached objects in a Hashtable.

The default Cache object would be stored directly in 
a variable, so that those that only need one Cache do not
pay the performance penalty of an additional Hashtable
lookup.

Rationale:  
Namespace issues mainly.  The most logical key
for an object in cache is not always a system wide
unique String.  The State example is demonstrative of this:
The logical way to index the US States would be by their number.
This is also the logical way to index the planets of the Solar
system, and the months of the year, leading to possible conflicts.

This can of course be resolved to a certain extent with String
concatenation, as in

gcs.getObject("state" + stateNum);
gcs.getObject("planet" + planetNum);
gcs.getObject("month" + monthNum);

However, I do not like this.

The second issue is that some classes need an internal
Cache, and know better than a general caching service when the cache
should be cleared.  They could use the org.apache.util.cache.Cache
class directly, and clearCache() it when they seem fit.


2 - Drop the restriction that Cache keys must be Strings.
---------------------------------------------------------
The logical key for a cached object is not always a String, 
and since the underlying storage is a Hashtable, the restriction
seems unneccessary.


3 - Backup proposal
-------------------
Should the first proposal be accepted, but not the second,
I suggest that the org.apache.turbine.util.cache.Cache object do 
NOT have the String key restriction, but the restriction be 
retained in org.apache.turbine.services.cache.GlobalCacheService.



Magnus ?or Torfason


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to