Hi,
> I think you already gave some sort of description, but could you be more
> specific and verbose about what the patch is for?
There were several mails on the list. The main points are;
Fixed the clearCache routine - it was never removing stale objects due to a bug in the
use of the hashtable.
Added a method to CachedObject to allow its expiry time to be reset (it just resets
the created time to now).
Added a facility for people to register listeners to be notified when an object is
being removed from the cache.
I need this because I am using a custom db implementation (which I am not currently
looking at integrating with Turbine...) and I want to be put my db connection into the
cache - but to be notified when it is expired - so that I can close it and free its
resources.
An example of usage of this is as follows (I hope the indenting gets sent this time...)
// START OF SAMPLE CODE
Database db = null;
GlobalCacheService gs = null;
try
{
// Look for the item in the cache.
// If it doesn't exist or the item is stale,
// the cache will throw an exception.
gs = (GlobalCacheService)TurbineServices.getInstance()
.getService(GlobalCacheService.SERVICE_NAME);
CachedObject obj = gs.getObject(CACHE_NAME_FOR_DB);
// got a db object - reset its expiry date - indicating its been used recently
db = (Database)obj.getContents();
obj.resetExpires();
} catch(ObjectExpiredException gone)
{
db = org.melati.poem.odmg.ODMGFactory.getNewDatabase();
db.open("vgdb",Database.OPEN_READ_WRITE);
CachedObject obj = new CachedObject(db);
// add this anonymous listener to close the db when its removed from the cache
obj.addListener(new CachedObjectListener() {
public void cachedObjectFinalizer(CachedObject cobj) {
Log.note("in cachedObjectFinalizer for "+cobj);
try {
Database cdb = (Database)cobj.getContents();
cdb.close();
} catch (ODMGException exc) {
Log.error(exc);
}
}
});
gs.addObject(CACHE_NAME_FOR_DB, obj);
}
return db;
// END OF SAMPLE CODE
> Also, I personally
> won't tend to look at any patches that aren't generated as unidiffs
(i.e. `cvs diff -u`). Thanks Chris.
I will submit a unidiff patch tonight (the code is at home, if only this firewall
didn't limit us to port 80 only...).
Regards,
Chris
---
"surely it is madness to accept life as it is and not as it could be"
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]