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 "Westfall, Eric Curtis" <ew...@indiana.edu> on 2006/04/22 04:14:51 UTC
Question about two-level cache
Hello, I'm wondering if anyone out there has experience using OJB's
two-level caching. I am attempting to use a two-level cache to help
speed up an application I'm working on and I'm noticing some issues that
I'm curious about.
It appears that, even if my object is already in the application cache,
OJB is still issuing the SQL to query for the object (verified using
P6Spy). Is this what's actually happening or am I mistaken? I can see
in certain cases where OJB would need to run the query in order to get a
set of primary keys to check the cache for, however, if I'm doing a
query by the primary key shouldn't it just go straight to the
application cache without hitting the database? I'm using OSCache as my
application cache, here's my configuration:
<object-cache
class="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl">
<attribute attribute-name="cacheExcludes" attribute-value=""/>
<attribute attribute-name="applicationCache"
attribute-value="edu.iu.uis.database.ObjectCacheOSCacheImpl"/>
<attribute attribute-name="copyStrategy"
attribute-value="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$Cop
yStrategyImpl"/>
<attribute attribute-name="forceProxies" attribute-value="false"/>
</object-cache>
Thanks in advance,
Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Question about two-level cache
Posted by Bruno CROS <br...@gmail.com>.
Hi,
I experienced Two Level Cache Impl. Have a look to mail archives about
TwoLevelCacheImpl. Beware of checkpoints inside batch loops. Using
checkpoints make cached objects quantity growing until commit. If you have
to, replace checkpoints by commit/begin.
Did you try the ObjectCacheDefaultImpl instead of OSCacheImpl ?
If you do ReportQuery or read Collections with criteria, then i beleive that
cache is not used (partially used in Collection retrieving). I mean SQL
query is done , to find data / or PK. So you can see queries crossing in
P6spy.
I'm interrested in your experiences of 2 Level Cache, especially in the
setting with the kind of model/processes.
Regards.
On 4/22/06, Westfall, Eric Curtis <ew...@indiana.edu> wrote:
>
> Hello, I'm wondering if anyone out there has experience using OJB's
> two-level caching. I am attempting to use a two-level cache to help
> speed up an application I'm working on and I'm noticing some issues that
> I'm curious about.
>
> It appears that, even if my object is already in the application cache,
> OJB is still issuing the SQL to query for the object (verified using
> P6Spy). Is this what's actually happening or am I mistaken? I can see
> in certain cases where OJB would need to run the query in order to get a
> set of primary keys to check the cache for, however, if I'm doing a
> query by the primary key shouldn't it just go straight to the
> application cache without hitting the database? I'm using OSCache as my
> application cache, here's my configuration:
>
> <object-cache
> class="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl">
> <attribute attribute-name="cacheExcludes" attribute-value=""/>
> <attribute attribute-name="applicationCache"
> attribute-value="edu.iu.uis.database.ObjectCacheOSCacheImpl"/>
> <attribute attribute-name="copyStrategy"
> attribute-value="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$Cop
> yStrategyImpl"/>
> <attribute attribute-name="forceProxies" attribute-value="false"/>
> </object-cache>
>
> Thanks in advance,
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
Re: Question about two-level cache
Posted by Armin Waibel <ar...@apache.org>.
Hi Eric,
Westfall, Eric Curtis wrote:
> Hello, I'm wondering if anyone out there has experience using OJB's
> two-level caching. I am attempting to use a two-level cache to help
> speed up an application I'm working on and I'm noticing some issues that
> I'm curious about.
>
> It appears that, even if my object is already in the application cache,
> OJB is still issuing the SQL to query for the object (verified using
> P6Spy). Is this what's actually happening or am I mistaken?
The two-level cache hold a "flat" (without referenced objects) copy of
the cached object. If OJB lookup an object from cache the non-proxy,
auto-retrieve 1:n and n:m references of the cached flat object have to
be materialized too. In this case OJB query the referenced objects.
Too avoid this use proxied references
http://db.apache.org/ojb/docu/guides/basic-technique.html#Using+a+Single+Proxy+for+a+Whole+Collection
or the 'forceProxies' attribute
http://db.apache.org/ojb/docu/guides/objectcache.html#ObjectCacheTwoLevelImpl
> I can see
> in certain cases where OJB would need to run the query in order to get a
> set of primary keys to check the cache for, however, if I'm doing a
> query by the primary key shouldn't it just go straight to the
> application cache without hitting the database?
yep, if you lookup objects by Identity
http://db.apache.org/ojb/docu/tutorials/pb-tutorial.html#Find+object+by+primary+key
except if the object has non-proxy, auto-retrieve 1:n and n:m references
- see above.
regards,
Armin
> I'm using OSCache as my
> application cache, here's my configuration:
>
> <object-cache
> class="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl">
> <attribute attribute-name="cacheExcludes" attribute-value=""/>
> <attribute attribute-name="applicationCache"
> attribute-value="edu.iu.uis.database.ObjectCacheOSCacheImpl"/>
> <attribute attribute-name="copyStrategy"
> attribute-value="org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$Cop
> yStrategyImpl"/>
> <attribute attribute-name="forceProxies" attribute-value="false"/>
> </object-cache>
>
> Thanks in advance,
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org