Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Transactable and Threadsafe Java Object Cache

Reply
Thread Tools

Transactable and Threadsafe Java Object Cache

 
 
toqeer
Guest
Posts: n/a
 
      06-28-2004
Hi All
My question is regarding the need of another caching APIs or
framework.
In my last project we handled the transactions on business layer
controller, which commit or rollback the transaction based on the
success or error in updating the database. We were not using EJBs but
if I compare it with EJBs then it's like CMT for stateless session
EJBs. As this application was data intensive so we decided to
implement simple cache to hold read-only objects in memory. But
developers also used this simple solution for other objects. As a
result in business methods the developer update the cache if database
is updated successfully. Now the cache was read and updated through
out in application and soon updating and rolling back the cache become
complex and error prone.
Then we realised the importance of cache that can be used seamlessly
at persistence layer and satisfy some basic requirements like

Thread Safe
If multiple users are updating same object, cache should remain
consistent with DB, also if one object is being updated the other
thread will see the old copy (last committed copy) without blocking
itself.

Transact-able
If a transaction involves multiple objects to be updated in DB, each
object is updated in DB and cache independently. In case of error
during updating one of the object the business layer controller will
roll back the data base and also rollback the cache like
cache.rollback();

Seamless
No application layer code is aware of the cache accept the
persistence layer.

My emphasis was on thread-safe and transact-able cache, because it was
the main pain for us to manage through out the application. I tried my
best to find such cache, but didn't succeed. Then I decided to build
my own cache API to do the job and fortunately successfully built such
cache and we got rid of all nasty errors and code, our business layer
become simpler and error free. Initially I implemented READCOMMITTED
isolation level, as it was enough in my case.

Now I'm thinking to refactor and enhance the cache APIs so that it can
be used in other projects having same requirements and make it
open-source so that other developers can get benefit for it.
I'm not sure whether such thing is available already in the market.
I'm not sure whether such functionality has any importance for others.

I want some feedback from developer community regarding the importance
and redundancy of such work. So that I do not re-invent the wheel and
also do not spent my time on some thing won't help others.
Your feedback is very import for me.

Regards,
Toqeer Sardar.
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      06-28-2004
toqeer wrote:
> My question is regarding the need of another caching APIs or
> framework.


JCS or ehcache might be worth a look. I haven't looked through and
verified all of your requirements (and I probably won't), but those are
fairly common packages to do this. Certainly Hibernate is able to use
ehcache in an environment with transactions and such.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
toqeer
Guest
Posts: n/a
 
      06-29-2004
Chris Smith <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)> ...
> JCS or ehcache might be worth a look. I haven't looked through and
> verified all of your requirements (and I probably won't), but those are
> fairly common packages to do this. Certainly Hibernate is able to use
> ehcache in an environment with transactions and such.


Thanks for your feedback, I have looked at ehcache specially because
hibernate use this cache and also provide transaction facility. I have
not seen in the documentation that the ehcache provide the ability to
commit or rollback, also there is no information regarding if multiple
threads are reading/updating same object in cache.
So I assume that it's the Hibernate that provide the transaction
functionality not the ehcache.

Regards,
Toqeer Sardar.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java DAO pattern: singleton and threadsafe? koenxjans@gmail.com Java 4 04-15-2008 02:35 PM
Is this static method threadsafe? =?Utf-8?B?RGlmZmlkZW50?= ASP .Net 3 01-14-2006 12:51 AM
Threadsafe VB =?Utf-8?B?QXJuZQ==?= ASP .Net 5 04-27-2005 05:12 PM
<classname>.class constuction not threadsafe ? Chris Uppal Java 1 09-29-2003 09:52 AM
are static functions threadsafe? David ASP .Net 2 07-28-2003 11:50 PM



Advertisments