-
Notifications
You must be signed in to change notification settings - Fork 13
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
Mechanism for invalidating (parts of) the cache #5
Comments
I like the idea of using the scope key for the invalidate. It's simple and predictable. I was also thinking of tagging a command run with multiple tags, that would provide some further granularity. Using --scope would be the same as tagging, just using a single tag.
Perhaps --invalidate-or, --invalidate-and to be explicit, otherwise it's ambiguous. Maybe it can fail if --invalidate is specified with multiple tags with a message suggesting --invalidate-and/--invalidate-or. Just an idea. I'm glad I found this project, I was planning to write pretty much exactly this, and in Rust. |
Tags are an interesting idea; would you mind filing a separate FR with some more thoughts on that, e.g. how you might use them (beyond invalidation)? Invalidation via the existing scoping mechanism is straightforward and easy, but it requires some form of collaboration amongst callers. For example if multiple callers are caching reads to a database and then one caller makes a cache-invalidating write they would need some way to notify the other callers to update their scope value. Obviously achievable (e.g. by storing the scope name in a file all callers share), but not straightforward. Glad you like the project, it's something I've wanted to implement for a long time! |
Related: the newly added |
Idea: reimplement scopes as a modtime file in the cache directory. Then scope-wide invalidation would simply involve This needs a little more thought and experimentation, but if someone's interested in playing around with it this would probably be a reasonable PR to pull together. |
An easy option is to add an
--invalidate
flag that, rather than retrieving the command simply deletes the cache key associated with the given command, like so:But it might be preferable to support some sort of more powerful invalidation, such as the ability to invalidate all calls to a given command, e.g.:
However
bkt
doesn't currently have any way to introspect the cache like this, short of a linear search. That might be fine, but otherwise either the key space would need to be redesigned or some secondary index would need to be maintained.Also
--scope
can be used to invalidate the cache, as long as all callers participate in using the right scope.The text was updated successfully, but these errors were encountered: