Re: Question about Caching.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Apr 21 2009 - 06:58:39 EDT

  • Next message: Nikos Paraschou: "Re: Question about Caching."

    Yes, this is normal. Altering parameters changes the query, so in two
    case you end up with two different queries behind the scenes, each
    cached separately.

    Andrus

    On Apr 21, 2009, at 1:50 PM, Nikos Paraschou wrote:
    > Στις 21-04-2009, ημέρα Τρι, και ώρα 13:21 +0300, ο/
    > η Andrus Adamchik
    > έγραψε:
    >>> Shouldn't it first look in cache?
    >>
    >>
    >> Yes it should. Are you using the same set of parameters in both
    >> cases?
    >
    > In the first case I am just calling the query "selectVehicles" which
    > is
    > stored in DataMap without defining any parameters. All vehicles are
    > returned.
    >
    > In the second case I want to retrieve a specific vehicle so I define
    > the
    > parameter plate
    >
    > params.put("plate", "koz-6657") and call
    >
    > performQuery("selectVehicles", params, false);
    >
    > The second call doesn't retrieve the requested vehicle from the cache
    > but instead, it sends a query to the DB.
    >
    > Why is this happening? Is it normal?
    >
    >
    >> And also which version of Cayenne is this?
    >
    > I am using Cayenne 2.0.4.
    >
    >>
    >> Andrus
    >>
    >>
    >> On Apr 21, 2009, at 12:28 PM, Nikos Paraschou wrote:
    >>
    >>> Hello,
    >>>
    >>> I created an Object Select Query in the Modeller which selects *
    >>> from
    >>> table Vehicles. The query has a qualifier (plate = $plate). In
    >>> Result
    >>> Caching I selected Shared Cache and unchecked the checkbox Refresh
    >>> Results.
    >>>
    >>> I wrote the following code:
    >>>
    >>> Map params = new HashMap();
    >>> params.put("plate", "koz-6657");
    >>>
    >>> List allVehicles = context.performQuery("selectVehicles",
    >>> false);
    >>> List specificVehicle = context.performQuery("selectVehicles",
    >>> params, false);
    >>>
    >>> I noticed that the first call of performQuery stores the retrieved
    >>> Vehicle Objects in cache.
    >>> But the second call, instead of getting the specific vehicle from
    >>> cache
    >>> it sends a query to the database.
    >>>
    >>> Why is this happening? Shouldn't it first look in cache?
    >>>
    >>> Thank you,
    >>> Nikos Paraschou
    >>>
    >>>
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Apr 21 2009 - 07:00:17 EDT