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

FileSystemCache files still persist even after expiration? #45

Open
stevenqzhang opened this issue Feb 12, 2024 · 1 comment
Open

FileSystemCache files still persist even after expiration? #45

stevenqzhang opened this issue Feb 12, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@stevenqzhang
Copy link

It seems like with a FileSystemCache, expired caches are still perisisted on disk unless the cache key is overwritten by a fresher value?

is this by design? or would it be a enhancement to autodelete expired cache entries?

Took a cursory glance at https://github.com/mistval/node-fetch-cache/blob/master/src/classes/caching/file_system_cache.ts#L23 and it seems to corroborate with my experience

@mistval mistval added enhancement New feature or request help wanted Extra attention is needed labels Feb 12, 2024
@mistval
Copy link
Owner

mistval commented Feb 12, 2024

Hi,

Yes you're right, and I think it would be an enhancement to autodelete expired cache entries so they don't hang around taking up disk space.

It would have to be done in a way that works across process restarts and multiple processes, so it couldn't just be a setTimeout() (like it is in MemoryCache). Perhaps a cache entry that contains an array of expiring entries and their expiration time, and poll that, although that array could become large and inefficient to parse into memory. If done that way, it might have to be optional behavior.

It might make sense to just have it be a feature of a new SQLiteCache or such, where the storage format can support efficiently querying for expired entries. Not sure if there's a good way to do that with cacache which is the backing store for FileSystemCache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants