Class <Interface> CachePolicy
publicA service which an application may provide to the store via
the store's lifetimes
property to configure the behavior
of the CacheHandler.
The default behavior for request lifetimes is to never expire
unless manually refreshed via cacheOptions.reload
or cacheOptions.backgroundReload
.
Implementing this service allows you to programatically define when a request should be considered expired.
didRequest [Optional] (request, response, identifier, store) Void public
Defined in ../packages/store/src/-private/cache-handler.ts:94
- request
- ImmutableRequestInfo
- response
- ImmutableResponse
- identifier
- StableDocumentIdentifier | null
- store
- Store
- returns
- Void
Invoked when a request has been fulfilled from the configured request handlers. This is invoked for both foreground and background requests once the cache has been updated.
Note, this is invoked regardless of whether the request has a cache-key.
isHardExpired (identifier, store) Boolean public
Defined in ../packages/store/src/-private/cache-handler.ts:45
- identifier
- StableDocumentIdentifier
- store
- Store
- returns
- Boolean
true if the request is considered hard expired
Invoked to determine if the request may be fulfilled from cache if possible.
Note, this is only invoked if the request has a cache-key.
If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response.
isSoftExpired (identifier, store) Boolean public
Defined in ../packages/store/src/-private/cache-handler.ts:62
- identifier
- StableDocumentIdentifier
- store
- Store
- returns
- Boolean
true if the request is considered soft expired
Invoked if isHardExpired
is false to determine if the request
should be update behind the scenes if cache data is already available.
Note, this is only invoked if the request has a cache-key.
If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers.
willRequest [Optional] (request, identifier, store) Void public
Defined in ../packages/store/src/-private/cache-handler.ts:79
- request
- ImmutableRequestInfo
- identifier
- StableDocumentIdentifier | null
- store
- Store
- returns
- Void
Invoked when a request will be sent to the configured request handlers. This is invoked for both foreground and background requests.
Note, this is invoked regardless of whether the request has a cache-key.