Returns an Express RequestHandler that caches GET responses with a 2xx
status code.
X-Cache: MISS.X-Cache: HIT.GET requests are forwarded to next() unchanged.Optionaloptions: MemorizeCallOptionsOptional per-route options (e.g. TTL override).
Removes all entries from the cache and emits a MemorizeEventType.Delete event for each.
Removes a single entry from the cache and emits a MemorizeEventType.Delete event.
The full request URL to invalidate.
true if the entry existed and was removed, false otherwise.
Returns all active (non-expired) cache entries as a plain object keyed by URL.
Registers a listener for cache events.
| Event | When |
|---|---|
MemorizeEventType.Set |
A response is stored |
MemorizeEventType.Delete |
An entry is removed via delete() or clear() |
MemorizeEventType.Expire |
An entry's TTL elapses |
MemorizeEventType.Empty |
The last entry is removed, cache is now empty |
The cache instance returned by memorize.
It is both a callable that produces Express middleware and a namespace for cache management methods and event hooks. All middleware created from the same
Memorizeinstance share a single underlying store.Example