Options for a cached resource.
- Source
Example
{
key: 'user:123',
loader: async () => Promise<User>,
ttl: 300000,
strategy: 'swr',
tags: ['user'],
storage: 'memory',
}Members
key :CacheKey
The cache key.
Type:
- Source
loader :function
The loader function to fetch the data.
Type:
- function
- Source
storage :'memory'|'local'|'session'
The storage to use for the cached entry.
Type:
- 'memory' |
'local' | 'session'
- Source
strategy :'cache-first'|'network-first'|'swr'
The caching strategy to use.
Type:
- 'cache-first' |
'network-first' | 'swr'
- Source
tags :Array
The tags for the cached entry.
Type:
- Array
- Source
ttl :number
The time-to-live for the cached entry.
Type:
- number
- Source