Transactable and Threadsafe Java Object Cache

Discussion in 'Java' started by toqeer, Jun 28, 2004.

  1. toqeer

    toqeer Guest

    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.
    toqeer, Jun 28, 2004
    #1
    1. Advertising

  2. toqeer

    Chris Smith Guest

    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
    Chris Smith, Jun 28, 2004
    #2
    1. Advertising

  3. toqeer

    toqeer Guest

    Chris Smith <> wrote in message news:<>...
    > 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.
    toqeer, Jun 29, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David

    are static functions threadsafe?

    David, Jul 29, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    480
    David
    Jul 29, 2003
  2. =?Utf-8?B?QXJuZQ==?=

    Threadsafe VB

    =?Utf-8?B?QXJuZQ==?=, Apr 26, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,557
    Kevin Spencer
    Apr 27, 2005
  3. =?Utf-8?B?RGlmZmlkZW50?=

    Is this static method threadsafe?

    =?Utf-8?B?RGlmZmlkZW50?=, Jan 13, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    459
    Bruce Barker
    Jan 14, 2006
  4. Chris Uppal
    Replies:
    1
    Views:
    427
    Chris Uppal
    Sep 29, 2003
  5. Replies:
    4
    Views:
    2,503
Loading...

Share This Page