Skip to content

Some cache entries might never be released? #40

@detarkende

Description

@detarkende

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions