Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache.getAll fails to trigger refresh #971

Open
gissuebot opened this issue Oct 31, 2014 · 13 comments
Open

Cache.getAll fails to trigger refresh #971

gissuebot opened this issue Oct 31, 2014 · 13 comments
Labels

Comments

@gissuebot
Copy link

Original issue created by wasserman.louis on 2012-04-15 at 02:31 PM


http://stackoverflow.com/questions/10153724/google-guavas-cacheloader-loadall-vs-reload-semantics motivated the question of how one could do efficient bulk refreshes, if LoadingCache.getAll discovered many entries eligible for refresh.

There's clearly a sensible default implementation -- just do the asynchronous refreshes concurrently, as it's done now -- but I'm curious if it might merit its own method that can be overridden, and if that'd overly complicate the already-rather-complex Cache semantics.

@gissuebot
Copy link
Author

Original comment posted by [email protected] on 2012-04-18 at 07:19 AM


This raises the interesting point that currently getAll/loadAll doesn't trigger refresh if a custom loadAll implementation is provided.

I agree that with a custom loadAll method it would be somewhat tragic to trigger hundreds of independent refreshes. So maybe this is arguing for CacheLoader.reloadAll.

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2012-04-22 at 05:42 PM


I have to admit that I find it surprising that getAll doesn't trigger refreshes -- and I suspect users would, too...

@gissuebot
Copy link
Author

Original comment posted by [email protected] on 2012-05-30 at 07:45 PM


(No comment entered for this change.)


Labels: -Type-Enhancement, Type-Addition

@gissuebot
Copy link
Author

Original comment posted by outdooricon on 2012-09-11 at 03:27 PM


"getAll/loadAll doesn't trigger refresh if a custom loadAll implementation is provided."

Really glad that I read this... I haven't seen this documented anywhere. As a user, I definitely expected a refresh. I'm using loadAll to populate multiple entries in the cache using only a single db call. This is my use-case for needing a reloadAll as well...

@gissuebot
Copy link
Author

Original comment posted by [email protected] on 2012-11-09 at 11:21 PM


Issue #1201 has been merged into this issue.

@gissuebot
Copy link
Author

Original comment posted by [email protected] on 2012-11-09 at 11:23 PM


Charles and I like this plan now: After getAll() determines which keys we already have in the cache, it could check which of those are already stale, and include those in the set it queries. If any of those don't happen to come back, we still use the stale values for those.


Status: Accepted
Labels: -Type-Addition, Type-Defect

@gissuebot
Copy link
Author

Original comment posted by [email protected] on 2013-03-12 at 06:43 PM


(No comment entered for this change.)


CC: [email protected]

@Dichotomia
Copy link

I am facing the same issue with cached calls to database. The status of the issue is accepted. Are there any news about the developpement of a solution?

@ben-manes
Copy link
Contributor

This should work properly in the rewrite. There should probably be variants of these tests for the async cache, though. A bulk refresh is not supported yet.

@Dichotomia
Copy link

I have still the same problem. Automatic refresh calls only load and not loadAll.

[main] INFO com.jcabi.aspects.aj.NamedThreads - jcabi-aspects 0.22.1/58f97a9 started new daemon thread jcabi-loggable for watching of @loggable annotated methods
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #loadAll('[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'): '{0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9}' in 162,75µs
[main] INFO com.dichotomia.tests.guava.CacheExample - #getAll([[0‥10)]): '{0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9}' in 17,07ms
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(0): '0' in 30,96µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(1): '1' in 17,88µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(2): '2' in 11,85µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(3): '3' in 8,43µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(4): '4' in 18,06µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(5): '5' in 23,26µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(6): '6' in 21,23µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(7): '7' in 9,26µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(8): '8' in 7,80µs
[main] INFO com.dichotomia.tests.guava.CacheLoaderExample - #load(9): '9' in 7,87µs
[main] INFO com.dichotomia.tests.guava.CacheExample - #getAll([[0‥10)]): '{0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9}' in 12,03ms

@ben-manes
Copy link
Contributor

For my side this is documented as #7 to support bulk refresh. I'm wrapping up v2 and not sure if this will make it.

@hmit
Copy link

hmit commented Oct 29, 2018

Hey, Is there an alternate way to trigger this other than calling refresh on all the keys periodically?

@raghsriniv raghsriniv added the P3 label Jun 24, 2019
@cpovirk
Copy link
Member

cpovirk commented Jul 25, 2019

Not sure where we left this. It seems like better docs would be good, but behavior changes are unlikely now that we point people to Caffeine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants