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

LoadingCache#getAll not maintaining order in returned map #267

Closed
marceloverdijk opened this issue Sep 13, 2018 · 4 comments
Closed

LoadingCache#getAll not maintaining order in returned map #267

marceloverdijk opened this issue Sep 13, 2018 · 4 comments

Comments

@marceloverdijk
Copy link
Contributor

When I have an empty LoadingCache and I do something like:

var map = customerCache.getAll(List.of(1, 2, 3, 4, 5);

the returned map contains the keys (ordered) 1, 2, 3, 4, 5.

Now, when I do the following with an empty cache:

var map = customerCache.getAll(List.of(4, 5);
// map contains keys (ordered) `4, 5`

map = customerCache.getAll(List.of(1, 2, 3, 4, 5);
// map contains keys (ordered) `4, 5, 1, 2, 3` 

It seems the missing keys are added to the end as 4, 5 were already cached.

I would have expected the order as requested (1, 2, 3, 4, 5).

@ben-manes
Copy link
Owner

Yes, this is the same as #220 where I misread the Guava behavior. It wasn't a guarantee but we do try to be consistent with Guava, and I misread to emulate what I thought was a bug (but created one here instead!).

@marceloverdijk
Copy link
Contributor Author

Oh I missed #220.
Is this something that will be fixed in Caffeine?
Because of this I can't use the loadAll functionality unfortunately as I don't know the order of the keys I received... I was looking for loadAll to avoid key by key queries to a backend.

@ben-manes
Copy link
Owner

It will be fixed, but hasn't been yet. I've been swamped lately and I'm not sure when I'll get through the backlog of tasks here. Sorry for that.

Can you sort at the getAll call-site for now?

@marceloverdijk
Copy link
Contributor Author

I unfortunately don't know the order on the all-site. But I will figure something out (maybe just not doing bulk loads at this time). Let's close this one and I will track #220.

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

No branches or pull requests

2 participants