cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Further on modeler problems and a Question..
Date Tue, 21 May 2019 05:42:43 GMT
>>  Is there a best practice for this use case?

Using query cache is the best practice. "local cache" is the fastest, but it is local to a
given ObjectContext. "shared cache" is a bit slower, but works across contexts and still avoids
hitting the DB. 

  // this query can be rerun any number of times without hitting the DB

You will need to do a bit of extra setup to enable manage cache in your runtime, but it is
usually worth it. In a Bootique app you would additionally include these dependencies to hook
up Ehcache framework:


You can leave it at that, or can configure it further to setup cache size and expiration policies.
For this you can create an ehcache file somewhere on classpath, where you can control expiration
times, etc.:


    <!-- Used by Cayenne for queries without explicit cache groups. -->
    <cache alias="cayenne.default.cache">
            <ttl unit="minutes">1</ttl>

And link it in your bootique config:

    - "classpath:com/foo/ehcache.xml"



> On May 20, 2019, at 7:25 PM, John Huss <> wrote:
> Just by querying the table at startup you can load it into the Object cache
> (if your shared cache is enabled, which it is by default). However if you
> exceed the size of the shared cache it will eventually evict those objects
> and re-fetch them one at a time as needed (which is bad).
> On Mon, May 20, 2019 at 11:09 AM Tony Giaccone <> wrote:
>> I also have Cayenne Modeler at version 4.01 and that starts up with out a
>> problem. So I am even more confused.  The 4.0 release version seems to work
>> fine and keeps the same version number in the model files so I'll be using
>> that.
>> Now the question that started this whole process.  I have a table in the
>> database that's essentially a look up table, it has several thousand rows,
>> and I'd like to just read it in once and then use it across different
>> incoming requests.  Is there a best practice for this use case?
>> Tony

View raw message