CachedResourceOptions

Options for a cached resource.

Example

{
  key: 'user:123',
  loader: async () => Promise<User>,
  ttl: 300000,
  strategy: 'swr',
  tags: ['user'],
  storage: 'memory',
}

Members

key :CacheKey

The cache key.

loader :function

The loader function to fetch the data.

Type:
  • function

storage :'memory'|'local'|'session'

The storage to use for the cached entry.

Type:
  • 'memory' | 'local' | 'session'

strategy :'cache-first'|'network-first'|'swr'

The caching strategy to use.

Type:
  • 'cache-first' | 'network-first' | 'swr'

tags :Array

The tags for the cached entry.

Type:
  • Array

ttl :number

The time-to-live for the cached entry.

Type:
  • number