You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Alex Bates <ab...@san.rr.com> on 2003/06/02 06:44:27 UTC

OJB read/write cache - beware the synchronized bottleneck

Has anyone implemented a read/write cache for use with OJB?

This article goes over how to implement, and links to some code for
ReadWriteLock (and ConcurrentHashMap):
http://www.theserverside.com/resources/article.jsp?l=Readers-Writers

However, my real question is: would it be possible to implement such a cache
for use with the J2EE version of OJB?  Since you can't use threads or the
threading API, it appears it would not.  If that's the case, I supposed the
read/write cache would only be able to run in the servlet layer?

Alex


Re: OJB read/write cache - beware the synchronized bottleneck

Posted by Thomas Mahler <th...@web.de>.
Hi Alex,

Alex Bates wrote:
> Has anyone implemented a read/write cache for use with OJB?
> 
> This article goes over how to implement, and links to some code for
> ReadWriteLock (and ConcurrentHashMap):
> http://www.theserverside.com/resources/article.jsp?l=Readers-Writers

In our ODMG implementation we have a peesimistic locking mechanism based 
on a MROW (many readers one writer) scheme. It's sitting on top of the 
cache. See http://db.apache.org/ojb/lockmanager.html for details.

> 
> However, my real question is: would it be possible to implement such a cache
> for use with the J2EE version of OJB?  Since you can't use threads or the
> threading API, it appears it would not.  If that's the case, I supposed the
> read/write cache would only be able to run in the servlet layer?

One of the *really* cool OJB features is that the ODMG lockmanager is 
able to synchronize any number of clients possibly running in different 
JVMs, and/or across different physical machines!

To make this possible we are using persistent locks that are stored in 
the database.
If you want to use this feature you just have to set the following 
OJB.properties switch:

# The LockMapClass entry tells OJB which concrete LockMap
# implementation is to be used.
# If OJB is running on multiple concurrent clients it is recommended
# to use the PersistentLockMapImpl. It guarantees to provide
# Lockamanagement across multiple JVMs.
# If OJB is running in a single JVM (e.g. in a desktop app, or in a
# servlet engine) it is save to use the InMemoryLockMapImpl.
# Using it will result in a large performance gain.
LockMapClass=org.apache.ojb.odmg.locking.PersistentLockMapImpl
#LockMapClass=org.apache.ojb.odmg.locking.InMemoryLockMapImpl

cheers,
Thomas

> 
> Alex
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>