jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis Savo <ts...@IFILM.com>
Subject JCSWorker commit to CVS (was RE: CachingWorker)
Date Mon, 09 Aug 2004 19:18:42 GMT
It's been committed to CVS under the experimental package in

Comments and critique are ALWAYS welcome. We'll be testing this and
deploying it in our production environment shortly (with the new
PooledCacheEventQueue), so I'll let you know how that goes.

I'm not married to the names of these classes, so if someone has some better
names for it I'd love to hear them!

-Travis Savo <tsavo@ifilm.com>

-----Original Message-----
From: Travis Savo [mailto:tsavo@ifilm.com]
Sent: Monday, August 09, 2004 10:26 AM
To: 'Turbine JCS Developers List'
Subject: RE: CachingWorker

I'm nearing completion of this refactoring.

I changed the JCSWorker to take the region only in the constructor, and do
the JCS.getInstance() there. No more calling JCS.getInstance() every time!

JCSWorker.getResult() takes a Serializable Key, and a JCSWorkerHelper, which
is an interface consisting of: public Object doWork() throws Exception.

So the typical usage looks like:

public class someClass{
  private static final JCSWorker worker = new JCSWorker("someRegion");

  public Object getSomething(Serializable aKey){
    JCSWorkerHelper helper = new AbstractJCSWorkerHelper(){
      public Object doWork(){
        return /* Do some work here on the cache miss */;
    Object result = worker.getResult(aKey, helper);

AbstractJCSWorkerHelper is a basic implementation of JCSWorkerHelper for
convince. There's also methods with signatures for groups too.

The semantics of mutual exclusion still apply: If one person starts doing
the work, all subsequent identical requests will wait for the first one to
finish and then do cache gets, so there's no race condition where the work
gets done and put multiple times unnecessarily.

As an aside, it's trivial to extend this to perform additional operations on
objects coming out of cache. I'll post one for Hibernate which locks the
objects with a Hibernate Session.

I'll commit this to experimental later on once I've updated the Javadocs to
reflect the new interface.

-Travis Savo <tsavo@ifilm.com>

To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org

View raw message