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 962E2200C31 for ; Wed, 8 Mar 2017 22:31:11 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 914F3160B86; Wed, 8 Mar 2017 21:31:11 +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 B5CC3160B73 for ; Wed, 8 Mar 2017 22:31:10 +0100 (CET) Received: (qmail 43215 invoked by uid 500); 8 Mar 2017 21:31:09 -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 43186 invoked by uid 99); 8 Mar 2017 21:31:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Mar 2017 21:31:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 3C4D11A0738 for ; Wed, 8 Mar 2017 21:31:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.379 X-Spam-Level: *** X-Spam-Status: No, score=3.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id BBdgb-PewlfZ for ; Wed, 8 Mar 2017 21:31:06 +0000 (UTC) Received: from mail-ua0-f169.google.com (mail-ua0-f169.google.com [209.85.217.169]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 54D8160DBE for ; Wed, 8 Mar 2017 21:31:06 +0000 (UTC) Received: by mail-ua0-f169.google.com with SMTP id f54so53393465uaa.1 for ; Wed, 08 Mar 2017 13:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=/WAtGaFn4ZD9UPanCO3ipC+Gk1pjYHtXGU//jg/oWb0=; b=GSaODjVukTrWmY6HspicMn8TqVfAv4DDfdbU/sFrkXHyLx9B549tXnrgbheGLg09bw u2zub82VjPSkcgTG3dV44Mqje+xmpjNrP3incjb9nXjCBcKmLpIuDC9gIYGDPHCg4H0U NAdnT5tNwEqWbzvy/tTbDKWcF08/GwDmI6pcITPthkcyVVfyvCIUNbkJK0kohO6n48BA UuSUBSokYGAl11rz6kz0+bFz6bEGvfv8KdTljdGHJk4xlE0rsmDPK8xcDYAamA7OQhgr +rv3l+Yerzn6iikE5ThMg+NS7KbcaxLM+aqps//MXtK0hF2BKU69Vho6eEiVxyW07n/s vXGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=/WAtGaFn4ZD9UPanCO3ipC+Gk1pjYHtXGU//jg/oWb0=; b=Ll3VRIK8MEncvNnBlXD70KQ5Y6P0awg0RXLq1ECIxUuKDdXKHygstzF0Q1GmD+VMj3 EnZBEtPVukjst35UHonmX6tvucggZaYiV8grSwPbTaLlXHeOAhzZ/ExjjfPKSOHKhNXu wRnt7ZTp9Z370VuZ3r/gFwo3wepnbLQokCWWM+CsMc+GGP/GU/XOgu6iryn1q3Af0Thz o1NP80MHFHWXVI46FDAiWki7K40x2niJTfo8S4AZCClPvWAlivuhOO5d4d62kyOkc0AK d01PaJH3yadzsUJv0bDhWgBYsPLLkQdSAAHmRzYJQ+S6ELCPwf8tFqzwjuDPFLZeDlG5 CzEg== X-Gm-Message-State: AMke39ldKLWNSKRdCSgw069PnLmc7GGfLnUzXC8t6BpCG62xihvMo2o+/BPNrftjFVHIe8k9wLUh88loRl2rpg== X-Received: by 10.31.216.5 with SMTP id p5mr4363219vkg.170.1489008665610; Wed, 08 Mar 2017 13:31:05 -0800 (PST) MIME-Version: 1.0 References: <059088E3-0513-4391-BD3C-EC9AC94E56AE@selbstdenker.ag> <56910E23-F3C4-4337-B58D-DDFF76C38837@selbstdenker.ag> In-Reply-To: <56910E23-F3C4-4337-B58D-DDFF76C38837@selbstdenker.ag> From: John Huss Date: Wed, 08 Mar 2017 21:30:54 +0000 Message-ID: Subject: Re: ObjectCache To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=001a114ebf3094cfe4054a3ed851 archived-at: Wed, 08 Mar 2017 21:31:11 -0000 --001a114ebf3094cfe4054a3ed851 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Right On Wed, Mar 8, 2017 at 3:16 PM Musall, Maik wrote: > And unless I'm explictly creating a query cache somewhere in my > application, > I won't have one? > > > Am 08.03.2017 um 22:05 schrieb John Huss : > > > > Unless you are using a query cache then running an ObjectSelect will > always > > give you fresh data from the DB. > > On Wed, Mar 8, 2017 at 3:01 PM Musall, Maik > wrote: > > > >> Can someone confirm this? Will I always get fresh data from DB with an > >> explicit query, or am I at risk being returned stale data from a > >> context-local cache that doesn't even see changes that haven been > recorded > >> in the shared snapshot cache in the meantime, let alone in the databas= e? > >> > >> I'm still a bit puzzled and out of documentation about the question of > how > >> to control data freshness. Cayenne seems to be a bit different than EO= F > in > >> this regard, with it's multi-level caching. > >> > >> Maik > >> > >> > >>> Am 24.02.2017 um 23:24 schrieb Markus Reich < > markus.reich@markusreich.at > >>> : > >>> > >>> I think if you start a "standard" query it goes always against the DB= , > >> this > >>> would be the query cache but this is not implicit done, you have to u= se > >>> groups for that. > >>> Object cache as I understand works behind the scenes, when you access > >>> properties of you persistent entity with getters, then values where > read > >>> through the GraphManager from Cache. > >>> Only OID Queries and RelationalQueries can get their data from cache. > >>> Standard SelectQuery always runs a query on DB. But maybe I'm wrong := -/ > >>> > >>> Musall, Maik schrieb am Fr., 24. Feb. 2017 um > >>> 23:14 Uhr: > >>> > >>>> Hi Lon, > >>>> > >>>> so with a context-local cache, you would still execute a regular > query, > >>>> but that query would not actually hit the database but the cache wou= ld > >>>> return the result instead? Is it like a result set per query SQL > string > >>>> which is cached? I don't really understand how those local caches ar= e > >> keyed. > >>>> > >>>> If there is any Cayenne documentation explaining this which I missed= , > >> I'd > >>>> be happt to get a pointer to that. > >>>> > >>>> Maik > >>>> > >>>>> Am 24.02.2017 um 18:25 schrieb Lon Varscsak >: > >>>>> > >>>>> I built something similar in EOF to local cache, so I think I can > >> answer > >>>> at > >>>>> least part of the question. > >>>>> > >>>>> It=E2=80=99s not uncommon for me to have a complex set of queries t= o do > >> something > >>>>> like compute pricing on an order. Rather than having to maintain > many > >>>> tiny > >>>>> caches or ivars with query results, all of my code executes queries > to > >>>> get > >>>>> the data set it needs whenever the pricing calculation is called. = It > >>>> makes > >>>>> the code simpler, but gives you the performance of having stored th= e > >>>>> results yourself in an ivar (or dictionary). > >>>>> > >>>>> Add in EHCache and now you can control how long those objects live > >>>> (rather > >>>>> than the life of an ivar). If they get removed from cache due to > cache > >>>>> control settings, the next time through the code, it will refetch > them > >>>> but > >>>>> I don=E2=80=99t have to be aware of this from a code perspective. > >>>>> > >>>>> Where I=E2=80=99m still hung up, is that it=E2=80=99s common for me= to have many > parts > >> of > >>>>> my code that are not aware of each other that display/operate on th= e > >> same > >>>>> data, and I=E2=80=99m unsure how to update the cache (since there a= re > multiple > >>>>> local caches) in between those two components after commit (since > >> change > >>>>> propagation is turned off by default and even when on is in a > separate > >>>>> thread so I can=E2=80=99t assume the objects will be refreshed when= I need). > >>>>> > >>>>> -Lon > >>>>> > >>>>> On Fri, Feb 24, 2017 at 3:00 AM, Musall, Maik > >>>> wrote: > >>>>> > >>>>>> Hi all, > >>>>>> > >>>>>> I'd like to extend this question a bit. I just read the entire > >>>> performance > >>>>>> tuning chapter again [1], and I'm a bit puzzled especially about t= he > >>>>>> ObjectContext's local caches, which Andrus also recommended to use > in > >>>> the > >>>>>> "A way to refreshObject()" thread: > >>>>>> > >>>>>>> So instead of micro-optimizations with shared snapshot cache, you > >>>> should > >>>>>> use queries with cache groups and query cache. They get refetched > >> when a > >>>>>> cache group is flushed in response to an object commit. So > technically > >>>> you > >>>>>> are not reusing the snapshot cache, but it really doesn't matter. > The > >>>>>> benefit you get in code simplicity, consistency, and often > >> performance, > >>>>>> always outweighs that. Besides this approach is cluster-friendly. > >>>>>> > >>>>>> Coming from EOF I grew the habit of frequently creating short-live= d > >>>>>> ObjectContexts, so basically every page load uses it's own new > >>>>>> ObjectContext to get fresh data from the shared global cache, > because > >>>> other > >>>>>> users may have altered data between page loads. While working on a > >>>> page, I > >>>>>> have references to the objects that I need there anyway, so I don'= t > >>>>>> understand at all what that context-local cache mechanism should d= o > >> for > >>>> me, > >>>>>> unless that "create new contexts all the time" strategy is just > plain > >>>> wrong > >>>>>> for Cayenne-based applications? > >>>>>> > >>>>>> And even if I would use a longer-lived ObjectContext for something= , > >>>> where > >>>>>> would that local cache get in effect? Either I have references to > >>>> objects > >>>>>> anyway, or I would need to refetch them, which would go through to > the > >>>>>> database, right? In what case would I get a benefit from a local > >> cache? > >>>> I > >>>>>> didn't find answers to this in the Cayenne Guide. > >>>>>> > >>>>>> Thanks > >>>>>> Maik > >>>>>> > >>>>>> [1] https://cayenne.apache.org/docs/4.0/cayenne-guide/ > >>>>>> performance-tuning.html >>>>>> docs/4.0/cayenne-guide/performance-tuning.html> > >>>>>> > >>>>>> > >>>>>>> Am 23.02.2017 um 09:43 schrieb Markus Reich < > >>>> markus.reich@markusreich.at > >>>>>>> : > >>>>>>> > >>>>>>> Hi, > >>>>>>> > >>>>>>> I'm looking for a more detailed explaination of the caching > >> mechanism, > >>>> as > >>>>>>> we are running a quite important and big web application with > >> cayenne, > >>>> I > >>>>>>> want to fine tune, because we run in some performance issues. > >>>>>>> > >>>>>>> I only found this > >>>>>>> https://cayenne.apache.org/docs/3.0/individual-object-caching.htm= l > >>>>>>> > >>>>>>> In 4.0 docu I can't find anything > >>>>>>> > >>>>>>> br > >>>>>>> Meex > >>>>>> > >>>>>> > >>>> > >>>> > >> > >> > > --001a114ebf3094cfe4054a3ed851--