How the cache works ?

From: Jean-Paul Le Fèvre (jean-paul.lefevr..ea.fr)
Date: Wed Aug 01 2007 - 10:06:04 EDT

  • Next message: Andrus Adamchik: "Re: How the cache works ?"

    I don't understand how the caching mechanism works in cayenne 1.2 !

    My selections are implemented as follows :

          SelectQuery query = new SelectQuery(Simulation.class,
                              ExpressionFactory.matchExp("name", name));
          query.setFetchLimit(1);
          query.setName("SimulationSelection");
          query.setCachePolicy(QueryMetadata.SHARED_CACHE);

          List list = context.performQuery(query);

          if (list == null || list.size() < 1) {
              return null;
          }

          return (Simulation) list.get(0);

    A call to this code returns null even when a simulation exists.
    More horribly this kind of code returns a wrong object in some cases.
    Using LOCAL_CACHE gives the same wrong result.
    Setting SHARED_CACHE_REFRESH fixes the problem, but it simply means that
    the cache is not used.

    Moreover I don't know if there is a way to configure the size of the cache.

    As a result I'm wondering whether it is better to implement a cache in
    my own application.

    Regards,

    -- 
    ___________________________________________________________________
    

    Jean-Paul Le Fèvre * Mail : LeFevr..onteny.org



    This archive was generated by hypermail 2.0.0 : Wed Aug 01 2007 - 10:06:35 EDT