Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CA55C2009A8 for ; Tue, 17 May 2016 20:22:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C8DD21609F5; Tue, 17 May 2016 18:22:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1FBC31607A8 for ; Tue, 17 May 2016 20:22:34 +0200 (CEST) Received: (qmail 66353 invoked by uid 500); 17 May 2016 18:22:29 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 66340 invoked by uid 99); 17 May 2016 18:22:29 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 May 2016 18:22:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 92F0AC70E3 for ; Tue, 17 May 2016 18:22:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id u5Ra-olMIr6j for ; Tue, 17 May 2016 18:22:26 +0000 (UTC) Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 6A6B05F4E4 for ; Tue, 17 May 2016 18:22:25 +0000 (UTC) Received: by mail-oi0-f53.google.com with SMTP id v145so38737730oie.0 for ; Tue, 17 May 2016 11:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=eCglRltCA0xph5eDIOqmt/fUtUbwGohXQ6q58qRzO2Y=; b=W9D+JTPBpyIoHWmUd3Tlr0yG1Q8M0xV7zGvIrlDrnqtS4fNh8YdIwzv0mdflvKXYjh ZzAFQOZ1O5vPTKu1ny12jc7xJRw8Rxm/ZBicsR/QbUIBxe2lPraonoj9F1S/VyY2jMtf pJlApFzouAjC000hTzKZdMpEP4dF6XTdvLArBsxkP4O+udKQVgE/r94ChtZpGm5ZSkTp G7ofgEk6W7stU+LPL2TYNL5VQjZgU1iYFteRIMvnmSmKks7DE/4r010cVSmtcRyLTnwf WqegyCOQHZh9N/nvI3sHGEiC8y7hxbrL/aICt/XxBlczAOIiE+zDcVFhIrOM7koGjlFQ yWcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=eCglRltCA0xph5eDIOqmt/fUtUbwGohXQ6q58qRzO2Y=; b=OBEkn0c6sgW1xvH6fkX7yhE2D5RtgIp1VgMc1JKfUYXqEfQ/4bjzpGnK3Ix3V53YO0 SOG0twLoVSalnqKmPDOyu6znTLDX1/kSl90zG+l+iUzNt9+NPYZkPqDusWld9Tt/qfPT cxV2iBN5plLqpV/qLbkQ3wN5op32AREpRMTvS+7svyUmMs0xt7ZOlSnQe/TQcPkddmHK iZuHdk3dTo4JWKcGMgM9gEhj5ky0AIvwyp6KXgcVqsumbap/SgzviiQm2QRystuuju81 xDUisBcp1JvUteHse+Hpr/xcaK9p8FI7UcW7+gngj2va7mAZWvCK7c9LgMTyXMe5ZonP eGLQ== X-Gm-Message-State: AOPr4FVjvUhVgqMFg5RFpxn1J+3FSBK1l3X4fRaLTL+XqkfsjfpNv4ncBOf8rMsRqP+SKrbrsbHX2TSeuaR5CQ== X-Received: by 10.157.14.236 with SMTP id 99mr1554994otj.83.1463509344270; Tue, 17 May 2016 11:22:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.46.139 with HTTP; Tue, 17 May 2016 11:21:54 -0700 (PDT) In-Reply-To: References: From: Michael Gentry Date: Tue, 17 May 2016 14:21:54 -0400 Message-ID: Subject: Re: Caching Relationship Objects/Queries - Cayenne 3.1 To: Cayenne Users Content-Type: multipart/alternative; boundary=001a1137261897421d05330dd2fd archived-at: Tue, 17 May 2016 18:22:36 -0000 --001a1137261897421d05330dd2fd Content-Type: text/plain; charset=UTF-8 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 ]] > [image: [ Facebook ]] > [image: > [ LinkedIn ]] > [image: > [ YouTube ]] [image: [ > Twitter ]] [image: [ Blog ]] > [image: [ Instagram ]] > > --001a1137261897421d05330dd2fd--