You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
I ended up creating a new driver, since this impacted both performance and memory allocation compared to the default memory driver. Making all this an opt-in feature rather than a forced one.
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 usinglru-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):This made me think that by changing the current Map from
Map<string, any>
toMap<string, { data: any, meta: { ttl?: number | undefined, [key: string]: any }
and asetTimeout
with an optional driver option likettlAutoPurge
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
The text was updated successfully, but these errors were encountered: