-
Notifications
You must be signed in to change notification settings - Fork 165
Description
Describe the feature
I've been digging into memory
driver related issues and toolset (notably: #13, #168, #262).
What are the plans to add TTL and Meta to this driver? I cannot find a clear No, there is no plan because of XYZ
. The only mention of in-mem TTL support is a comment suggesting using lru-cache
, but its documentation states multiple times that it is not its primary use, and should be avoided if it is the only use (doc source):
If you truly wish to use a cache that is bound only by TTL expiration, consider using a Map object, and calling setTimeout to delete entries when they expire. It will perform much better than an LRU cache.
This made me think that by changing the current Map from Map<string, any>
to Map<string, { data: any, meta: { ttl?: number | undefined, [key: string]: any }
and a setTimeout
with an optional driver option like ttlAutoPurge
we could both add ttl and meta support without breaking changes at the small cost of memory increase and pulling the whole value just to access the metadata.
Another approach is to have a dedicated Map only for metadata, but generally I prefer pulling +10MB objects compared to risking the two Maps go out of sync (but, tbh, idk if I'm being paranoid)
Additional information
- Would you be willing to help implement this feature?