Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Antw.: [eclipselink-users] Caching read-all queries


Other apps do touch the database, but not every minute, and I was
planning on giving it an expiry time of just that.

Anyway, I've solved the problem using a query redirectors and ehcache.


On Thu, May 20, 2010 at 9:57 AM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
> Hi Zarar,
>  EclipseLink assumes multiple applications will be updating your database.
> With multiple applications, there is the possibility that rows will be added
> to tables outside of the knowledge of a single application.  As a result
> when you Read All objects, EclipseLink cannot assume it's cache knows about
> all the objects - therefore, it must go to the DB to retrieve the IDs of the
> objects that the query should return.  After the IDs are returned the cache
> is used for optimization.
>  If your application is designed in such a way that you know that it is the
> only application that will touch the database, or that you don't care what
> other applications add, there are a number of EclipseLink features that
> allow you to do Cache-only queries.  You can run queries that check the
> cache only, and you can run queries that cache their results and always
> return those results.  The question is, is that really what you want?
> -Tom
> Zarar Siddiqi wrote:
>> Hi,
>> So queries like returning a list of states or last year's items sold
>> will always result in a query being executed? I find it really hard to
>> believe that it's a feature that is lacking.
>> Thanks
>> Zarar
>> On Thursday, May 20, 2010, JAAP SPIERING <jaap.spiering@xxxxxxxxxx> wrote:
>>> Hi Zahar,
>>> I believe this question popped up on this list a couple of days ago as
>>> well, but I couldn't find it anymore.Anyway, ReadAllQueries always hit the
>>> database, because they need to determine what records are to be returned
>>> (there might be different ones in the database compared to when your query
>>> was last executed). When records are returned that are already stored in the
>>> cache, it will return the corresponding cached objects so there is some
>>> optimization there.
>>> regards,
>>> Jaap
>>> ----- Oorspronkelijk bericht -----
>>> Van: zarars@xxxxxxxxx
>>> Aan: eclipselink-users@xxxxxxxxxxx
>>> Verzonden: Donderdag 20 mei 2010 00:11:39 GMT +01:00 Amsterdam / Berlijn
>>> / Bern / Rome / St!
>>>  ockholm / Wenen
>>> Onderwerp: [eclipselink-users] Caching read-all queries
>>> I'm using 1.2 and have a couple cache related questions.
>>> Do read-all queries (ones using getResultList()) always hit the database?
>>> As I understand the docs, the "CheckCacheThenDatabase" hit only
>>> applies to read-object queries (ones using getSingleResult()).  In my
>>> app, I have a ton of queries that are candidates for caching, but they
>>> all use getResultList(). I've set an @Cache(expiry=60000) annotation
>>> on those entities and when I execute them, I keep seeing the queries
>>> printed in the logs.
>>> To me, this isn't the greatest behaviour since I'm executing the exact
>>> same query with the exact same parameters.  Shouldn't EclipseLink have
>>> a way of optimizing this?
>>> Thanks,
>>> Zarar
>>> _______________________________________________
>>> eclipselink-users mailing list
>>> eclipselink-users@xxxxxxxxxxx
>>>  selink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx

Zarar Siddiqi

Back to the top