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

Allow enumeration of PINCache #305

Open
vade opened this issue May 21, 2021 · 3 comments
Open

Allow enumeration of PINCache #305

vade opened this issue May 21, 2021 · 3 comments
Assignees

Comments

@vade
Copy link

vade commented May 21, 2021

Hello

Firstly, thank you for PINCache, its been a breeze to set up and work with, so much appreciated!

I'm wondering why the enumerateObjectsWithBlock and fam isn't part of the PinCaching protocol - it might be nice to be able to enumerate all objects in your cache(s) (without loading flushed to disk objects into ram unless you specifically request to do so).

I get there's likely nuances im not thinking of, but being able to enumerate your entire cache is a use case that's very helpful on my end as unintuitive as it is.

Obviously you can do that now with the memory and disk caches manually, but you run into cases the same object may be backed by both caches (hot and on disk).

I imagine there's nuances to equality checking (ensuring the hashes for the disk cache object and memcache objects match esp if a new object has to be deserialized to check for equality - could be slow).

Its early and I'm likely missing some subtle details - any chance for a global enumerateObjectsWithBlock which fast paths in ram and only loads the disk items that aren't hot? Could be nicer than having folks roll their own.

Much appreciated and thanks again.

@garrettmoon
Copy link
Collaborator

The history behind it not being in the PINCaching protocol is there was no clean way to keep the existing API. All the other methods matched one to one in disk and memory cache but the enumeration blocks for disk and memory are different. When we added the protocol we wanted to keep the existing API.

As far as adding a enumerateObjectsWithBlock method on PINCache, I don't see a particular problem with creating one (pull requests welcome!). It would likely require a new method on PINDiskCache which just enumerated _metadata and provided its keys.

@garrettmoon
Copy link
Collaborator

Sorry, didn't mean to close, will keep open as an enhancement request.

@garrettmoon garrettmoon changed the title Cache enumeration question / Possible feature request Allow enumeration of PINCache May 21, 2021
@vade
Copy link
Author

vade commented May 24, 2021

Cool. I may give that a go myself!

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

No branches or pull requests

3 participants