Menu

Post image 1
Post image 2
1 / 2
0

Layercache 2.0.0: Millisecond TTLs, Stale-Preserving Expiration, and Better Redis Coverage

DEV Community·날다람쥐·about 1 month ago
#5LXmw9Jo
Reading 0:00
15s threshold

Layercache 2.0.0 is out. This release is intentionally a major version because it changes the public TTL semantics from seconds to milliseconds. That is a breaking change, but it also makes Layercache much more consistent with Node.js timers, Redis PX / PTTL , and most JavaScript runtime APIs. What changed? Breaking: TTL values are now milliseconds Before 2.0.0 , TTL examples and parts of the public API used seconds. In 2.0.0 , TTL-related values are consistently milliseconds: const cache = new CacheStack ({ layers : [ memory , redis ], ttl : 60 _000 }) await cache . set ( " user:1 " , user , { ttl : 30 _000 , staleWhileRevalidate : 120 _000 , staleIfError : 300 _000 }) Enter fullscreen mode Exit fullscreen mode This applies to: layer defaults operation-level ttl negativeTtl staleWhileRevalidate staleIfError ttlJitter refreshAhead adaptive TTL policies TTL policy return values Redis writes now use PX , Redis TTL reads use PTTL , and CLI inspect output reports ttlMs .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More