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

Some cache entries might never be released? #40

Open
detarkende opened this issue Nov 30, 2024 · 0 comments
Open

Some cache entries might never be released? #40

detarkende opened this issue Nov 30, 2024 · 0 comments
Assignees
Labels

Comments

@detarkende
Copy link

public async getItem<T>(key: string): Promise<T | undefined> {
const item = await this.storage.getItem(key)
if (item?.meta?.ttl && this.isItemExpired(item)) {
await this.unsetKey(key)
return undefined
}
return item ? item.content : undefined
}

If I read your code correctly, you're only releasing cache entries when the user retrieves them and they are out of date.

So if my class method returns a huge object for an argument, but then I never call the method with the same argument again, then that entry will never be released? (In my case, I'm fetching metadata for movies, and it's fairly likely that the user clicks on a movie, then never returns to it, so I'm guessing that the query is never invalidated. Am I correct?)

This could be pretty serious if you use it with the FS container, because you could have an infinitely growing json file.

@havsar havsar self-assigned this Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants