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

git-file-utils: add ways to invalidate cache entries #5196

Open
dgellow opened this issue Sep 11, 2023 · 2 comments
Open

git-file-utils: add ways to invalidate cache entries #5196

dgellow opened this issue Sep 11, 2023 · 2 comments
Assignees
Labels
help wanted We'd love to have community involvement on this issue. package: git-file-utils priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@dgellow
Copy link

dgellow commented Sep 11, 2023

Is your feature request related to a problem? Please describe.

Hey there 👋. git-file-utils is a nice simple package that does its job fairly well, but I find myself wishing it would offer a way to invalidate its cached data.

On a project I'm currently working on (heavily based on release-please, which is using git-file-utils as part of its github client) I faced multiple times the situation where I recreate a branch or heavily change its content/history but have no way to invalidate cached data without recreating the whole cache from scratch.

Describe the solution you'd like

Something like this would be perfect for my use case:

const fileCache: RepositoryFileCache;
const oldContent = fileCache.getFileContents("my-file.json", "branch-a");

await recreateBranch({branch: "branch-a", onTopOf: "branch-b"})

// whole branch can be invalidated (I know that RepositoryFileCache is currently only for a single branch, but I see this as an implementation detail)
fileCache.invalidateBranch("branch-a")

// or maybe just the file I want
fileCache.invalidateFile("my-file.json", "branch-a")

const newContent = fileCache.getFileContents("my-file.json", "branch-a");

Describe alternatives you've considered

  • An alternative would be to pass a flag/option to the existing methods to bypass reading from the cache

Additional context

I think the context is fairly clear as it is, but I add provide more details if needed.

@dgellow dgellow added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 11, 2023
@chingor13
Copy link
Contributor

This seems like a reasonable feature request, but is not something we immediately have a need to implement. Is this something you'd be interested in contributing? We would be happy to accept a PR for this.

Perhaps an new invalidateBranch(branch: string): BranchFileCache | undefined which would return the exisiting BranchFileCache that we are invalidating (if it exists).

@chingor13 chingor13 added help wanted We'd love to have community involvement on this issue. package: git-file-utils labels Sep 11, 2023
@dgellow
Copy link
Author

dgellow commented Sep 11, 2023

Nice, sounds good. I think I should have a bit of time this week to create a PR. But no guarantees :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We'd love to have community involvement on this issue. package: git-file-utils priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants