You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Cypher ! <cy...@hotmail.com> on 2006/04/27 01:46:29 UTC

caching persistent objects

Hi
In am using the latest version Cayenne with Tapestry 4 on Oracle and deploying as a servlet to Tomcat 5. I have set up a filter for creating the DataContext. The problem I am having is the application is hitting the database for virtually every request and not caching any data at all. The QueryLogger is displaying all the database fetches and when a new session is created, the application continues to start from scratch so to speak. 
How do I enable shared caching and other types of caching and how do I turn the QueryLogger on and off? I have taken a look at the document on the Cayenne website but that detailed query caching. i am looking to apply application caching of persistent data.
Many thanks for your help.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Re: caching persistent objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 26, 2006, at 7:46 PM, Cypher ! wrote:
> how do I turn the QueryLogger on and off?

http://objectstyle.org/confluence/display/CAYDOC/Configuring+Logging

> The problem I am having is the application is hitting the database  
> for virtually every request and not caching any data at all. [...]  
> How do I enable shared caching and other types of caching

You need to understand that there is no single solution to persistent  
data caching that will address all situations, short of keeping the  
entire database in memory, but if you are using Oracle, this is  
probably not what you want. Still Cayenne provides a number of  
facilities to do smart caching. You'll need to understand them and  
apply as appropriate:

1. Query caching. I assume you've seen this page:

http://objectstyle.org/confluence/display/CAYDOC/Caching+Query+Results

A SHARED_CACHE policy is especially helpful when reading shared  
static data, such as a list of countries or us states, etc.


2. Prefetching - optimizing your queries:

http://objectstyle.org/confluence/display/CAYDOC/Prefetching


3. DataObjectUtils - object retrieval by PK will use shared cache if  
possible.


4. Relationship caching. This mostly applies to to-one relationships  
- cross-DataContext to-one relationships are automatically resolved  
from cache. You don't have to do anything.

Andrus