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

Is there a getAll method? #379

Open
soloman817 opened this issue Apr 17, 2020 · 8 comments
Open

Is there a getAll method? #379

soloman817 opened this issue Apr 17, 2020 · 8 comments

Comments

@soloman817
Copy link

From the source code, I see there is a removeAll method, but I cannot find a getAll method, does that exist?

@lewisjkl
Copy link
Collaborator

Hey @soloman817, there is not a getAll method in the current AbstractCache implementation. I think the main reasoning here is that although a getAll method could be implemented for a cache like Caffeine, it is going to be much more difficult and less performant for a cache like Redis or Memcached. At least as far as I know, those caches don’t expose an API for getting all of their contents, but I’d have to do a bit more digging to see for certain.

@soloman817
Copy link
Author

Thanks for the reply, I'm currently use Caffeine as a in-memory cache, and I like the API design a lot, but I do need a get all method. Would it be reasonable, that some abstract method can only be implemented with specific backend? Say it works for Caffeine, but for Redis, just throw exception?

@soloman817
Copy link
Author

Or, another solution would be, I use a separate cache to store the ids, then if I can query the cache on a set of id, that would be better, even possible for Redis

@lewisjkl
Copy link
Collaborator

Exposing a method that allows you to pass a set of keys sounds like a pretty good option to me. We can definitely look into adding a method like that. However, I think it probably makes sense for us to wait until #345 is finished before adding this functionality.

As a workaround in the meantime, you can always create your own Caffeine cache and pass it in to Scalacache (example in docs). Then you can query any methods direct on the cache that you need to.

@soloman817
Copy link
Author

Thanks!

@improved-broccoli
Copy link

improved-broccoli commented Oct 24, 2020

@lewisjkl A get method allowing to pass a set of keys would be nice for me too, I implemented a DynamoDB cache from AbstractCache and for performance reason, I need to leverage the Batch* API actions.
By the way, would you be interested by a scalacache-dynamodb module or you prefer to keep number of cache backend small (I saw some of them have been removed between 0.28 and 1.0.0)

@lewisjkl
Copy link
Collaborator

Hey @jbenoit2011, thanks for resurfacing this. We are waiting on the next major release of cats-effect to drop before we move forward with releasing version 1.0.0 officially. In the meantime, however, I would welcome a PR for adding that batch method that accepts a set of keys rather than a single one.

We are currently trying to keep the core of Scalacache as minimal as possible, which is why we removed some of the other cache backends (as you mentioned). We are working on moving scalacache to its own github group where we hope to be able to have other projects containing various cache backends. Once we have that up, then something like scalacache-dynamodb would be great!

@jtjeferreira
Copy link

By the way, would you be interested by a scalacache-dynamodb

@jbenoit2011 did you ever published this? I would be interested...

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

4 participants