cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <blackn...@gmail.com>
Subject Re: Caching Relationship Objects/Queries - Cayenne 3.1
Date Tue, 17 May 2016 18:21:54 GMT
Hi Frank,

I'm a little confused by this part:

"If we retrieve Object2 from the database, it is placed in the object
cache. Afterwards, if we retrieve Object1 via the getter in Object2,
Object1 is not cached. So, every time we make the request for Object1 via
the getter, another call is made to the database."

Are you saying:

object2 = // something that fetches object2
object1 = object2.getObject1(); // trips fault, fetches object1
object1 = object2.getObject1(); // trips fault, fetches object1

Or:

object2 = // something that fetches object2
object1 = object2.getObject1(); // trips fault, fetches object1
object2 = // refetch object2 from cache
object1 = object2.getObject1(); // trips fault, fetches object1

Thanks,

mrg


On Tue, May 17, 2016 at 9:32 AM, Frank Herrmann <
frank.herrmann@modernizingmedicine.com> wrote:

> Hello all,
>
> I have a question regarding how Cayenne does caching. Right now, if we
> retrieve an object from the database via Cayenne, it is placed in the
> object cache. However, in our experience, if we then retrieve another
> object via the relationship on the first object, it is not cached.
>
> A rough example:
>
> public class Object1 {
>     ... misc attributes ...
> }
>
> public class Object2 {
>     ... misc attributes...
>     private Object1 object1;
>
>     public Object1 getObject1() {
>         return object1;
>     }
> }
>
> If we retrieve Object2 from the database, it is placed in the object cache.
> Afterwards, if we retrieve Object1 via the getter in Object2, Object1 is
> not cached. So, every time we make the request for Object1 via the getter,
> another call is made to the database. I have fixed this for individual
> instances by using prefetches. However, our application is quite large, and
> I don't like the idea of tracking down case.
>
> Is there some way for Cayenne to place the relationship objects into the
> object cache the first time they are retrieved? We are using EhCache for
> our query caching, so if the object cache is not an options, is there a way
> to store these relationships in a short lived query cache?
>
> Thanks for the help.
>
> -Frank
>
> --
> FRANK HERRMANN
> SOFTWARE ENGINEER
>
> T: 561-880-2998 x1563
>
> E: frank.herrmann@modmed.com
>
>
>
> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> <http://instagram.com/modernizing_medicine>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message