|
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.
node-ts-cache/packages/core/src/cache-container/cache-container.ts
Lines 12 to 22 in d51ecfe
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.