Disabling caching for all entities in a certain DataMap

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Disabling caching for all entities in a certain DataMap

Hugi Thordarson
Hi all.
I’m working on a project where external applications modify the DB, so I have to disable caching (or probably better, make it valid for only a very short period of time) for all entities in a certain DataMap. What’s the easiest way for me to achieve this?

Cheers,
- hugi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disabling caching for all entities in a certain DataMap

Andrus Adamchik

> On Oct 25, 2016, at 3:30 PM, Hugi Thordarson <[hidden email]> wrote:
>
> Hi all.
> I’m working on a project where external applications modify the DB, so I have to disable caching (or probably better, make it valid for only a very short period of time) for all entities in a certain DataMap. What’s the easiest way for me to achieve this?
>
> Cheers,
> - hugi

Hi Hugi,

I recommend using EhCacheQueryCache and configuring expiration policies in ehcache.xml . This is all about *query* cache of course. But with proper query cache, object cache is refreshed as a side effect of query execution. You can install EhCacheQueryCache via Cayenne DI.

A second option is even better ... if you are using Bootique. The upcoming Bootique 0.21 integrates newer EhCache 3.x and provides both API and XML-based EhCache configs. Still need to document this, but in short, you drop bootique-cayenne-ehcache [1] in your app, and you already have EhCache with default settings working. Here is an API-config example:

Configuration<String, List> c = new MutableConfiguration<String, List>()
  .setTypes(String.class, List.class)
  .setExpiryPolicyFactory(...);

EhCacheModule.contributeConfiguration(binder).addBinding("somecayennecachegroup").toInstance(c);

Andrus


[1] https://github.com/bootique/bootique-cayenne/tree/master/bootique-cayenne-ehcache



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disabling caching for all entities in a certain DataMap

Andrew Willerding-2
I am experiencing this situation the for the first time where the
database is modified outside of my cayenne based application.
Unfortunately the explanation below means absolutely nothing to me.  
;-)  Neither my app nor the database is going to be highly utilized so
performance is not too much of a concern. Is there a way to simply force
all data retrieval to always go to the database and not the cache?  I'm
looking for some simple steps to follow and it's possible I've
overlooked the obvious.

Thanks,

Andrew


On 09/12/16 02:04 AM, Andrus Adamchik wrote:

>> On Oct 25, 2016, at 3:30 PM, Hugi Thordarson <[hidden email]> wrote:
>>
>> Hi all.
>> I’m working on a project where external applications modify the DB, so I have to disable caching (or probably better, make it valid for only a very short period of time) for all entities in a certain DataMap. What’s the easiest way for me to achieve this?
>>
>> Cheers,
>> - hugi
> Hi Hugi,
>
> I recommend using EhCacheQueryCache and configuring expiration policies in ehcache.xml . This is all about *query* cache of course. But with proper query cache, object cache is refreshed as a side effect of query execution. You can install EhCacheQueryCache via Cayenne DI.
>
> A second option is even better ... if you are using Bootique. The upcoming Bootique 0.21 integrates newer EhCache 3.x and provides both API and XML-based EhCache configs. Still need to document this, but in short, you drop bootique-cayenne-ehcache [1] in your app, and you already have EhCache with default settings working. Here is an API-config example:
>
> Configuration<String, List> c = new MutableConfiguration<String, List>()
>    .setTypes(String.class, List.class)
>    .setExpiryPolicyFactory(...);
>
> EhCacheModule.contributeConfiguration(binder).addBinding("somecayennecachegroup").toInstance(c);
>
> Andrus
>
>
> [1] https://github.com/bootique/bootique-cayenne/tree/master/bootique-cayenne-ehcache
>
>
>

Loading...