API Docs for: 5.3.1+9967eaf7
Show:

<Interface> LifetimesService Class

A 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.

Methods

didRequest [Optional]

(
  • request
  • response
  • identifier
  • store
)
Void public

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.

Parameters:

  • request ImmutableRequestInfo
  • response ImmutableResponse
  • identifier StableDocumentIdentifier | null
  • store Store

Returns:

Void:

isHardExpired

(
  • identifier
  • store
)
Boolean public

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.

Parameters:

  • identifier StableDocumentIdentifier
  • store Store

Returns:

Boolean:

true if the request is considered hard expired

isSoftExpired

(
  • identifier
  • store
)
Boolean public

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.

Parameters:

  • identifier StableDocumentIdentifier
  • store Store

Returns:

Boolean:

true if the request is considered soft expired

willRequest [Optional]

(
  • request
  • identifier
  • store
)
Void public

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.

Parameters:

  • request ImmutableRequestInfo
  • identifier StableDocumentIdentifier | null
  • store Store

Returns:

Void: