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 Thierry Hanot <th...@infovista.com> on 2003/12/26 11:18:46 UTC

Remark on the ObjectCacheDefaultImpl

Hello 
I had some problems with the ObjectCacheDefaultImpl , 
First : The constructor of this cache in the have some problem when we use
the parameter properties 
timeout = prop == null ? timeout : (new Long(prop.getProperty("timeout", ""
+ timeout)).longValue()*1000);

In the comment of the class the value timeout is already in millisecond , so
the is 1000 time the wanted value or the comment is wrong :)

 

My second problem is the use of the SoftReference . Why do you use the
SoftReference on the CacheEntry instead of the object itself .

 

As we cannot have any reference on those cache entries , the cache is
cleaned at almost every garbage collection..... ( the cache is very
ineffective )

So the documentation is wrong :

This implementation use SoftReference to wrap all cached objects. If the
cached object was not longer referenced by your application but only by the
cache, it can be reclaimed by the garbage collector. 


For exemple ( this test case could be reproduce every time )   :

Table Instance which has a reference on itself . Using proxies for accessing
to the other instance .

INSTANCE

ID    NAME LINKEDINSTANCE

1     I1        NULL

2     I2        1

 

load the instance i1 in instance1

load the instance i2 in instance2

 

access to i1 by the field LinkedInstance and a proxy, this could return a
proxy on instance1

or a proxy on a new object instance i1 which is reloaded from the DB ( which
is happening most of the time ) 

 

B.R 

 

Thierry