cache-manager
Classes
CacheManager
cloudflare-kv-adapter
Classes
CloudflareKVCacheAdapter
Interfaces
KVLike
in-memory-adapter
Classes
InMemoryCacheAdapter
noop-adapter
Classes
NoopCacheAdapter
perspectapi-ts-sdk
Modules
cache-managercloudflare-kv-adapterin-memory-adapternoop-adaptertypes
types
Interfaces
CacheAdapterCacheConfigCacheEntryCacheInvalidateOptionsCacheManagerOptionsCachePolicyCacheSetOptions
Type Aliases
CacheKeyPart
Interface: KVLike
Minimal interface matching CloudflareKvAdapter / CacheStorage from @perspect/shared.
Methods
clear()?
optionalclear():Promise<void>
Returns
Promise<void>
delete()
delete(
key):Promise<void>
Parameters
key
string
Returns
Promise<void>
deleteMultiple()?
optionaldeleteMultiple(keys):Promise<void>
Parameters
keys
string[]
Returns
Promise<void>
get()
get(
key):Promise<string|null>
Parameters
key
string
Returns
Promise<string | null>
put()
put(
key,value,options?):Promise<void>
Parameters
key
string
value
string
options?
expirationTtl?
number
Returns
Promise<void>
Interface: CacheAdapter
Methods
clear()?
optionalclear():Promise<void>
Optional clear method to wipe all entries for adapters that manage isolated namespaces.
Returns
Promise<void>
delete()
delete(
key):Promise<void>
Remove a cached entry.
Parameters
key
string
Returns
Promise<void>
deleteMany()?
optionaldeleteMany(keys):Promise<void>
Optional bulk delete implementation.
Parameters
keys
string[]
Returns
Promise<void>
get()
get(
key):Promise<string|null|undefined>
Retrieve a raw cache payload for the given key. Implementations should return undefined (or null) when the key does not exist or has expired.
Parameters
key
string
Returns
Promise<string | null | undefined>
set()
set(
key,value,options?):Promise<void>
Store a raw payload for the given key. Implementations MAY honour ttlSeconds natively; the cache manager will also persist expiry timestamps in the payload for adapters that do not have native TTL support.
Parameters
key
string
value
string
options?
ttlSeconds?
number
Returns
Promise<void>
Interface: CacheConfig
Extends
CacheManagerOptions
Properties
adapter?
optionaladapter?:CacheAdapter
defaultTtlSeconds?
optionaldefaultTtlSeconds?:number
Inherited from
CacheManagerOptions.defaultTtlSeconds
enabled?
optionalenabled?:boolean
Explicit flag to disable caching. Defaults to false when a cache configuration is supplied, so caching is considered enabled unless explicitly disabled.
keyPrefix?
optionalkeyPrefix?:string
Inherited from
CacheManagerOptions.keyPrefix
Interface: CacheEntry<T>
Type Parameters
T
T = unknown
Properties
expiresAt?
optionalexpiresAt?:number
metadata?
optionalmetadata?:Record<string,unknown>
tags?
optionaltags?:string[]
value
value:
T
Interface: CacheInvalidateOptions
Properties
keys?
optionalkeys?:string[]
tags?
optionaltags?:string[]
Interface: CacheManagerOptions
Extended by
CacheConfig
Properties
defaultTtlSeconds?
optionaldefaultTtlSeconds?:number
keyPrefix?
optionalkeyPrefix?:string
Interface: CachePolicy
Extends
CacheSetOptions
Properties
metadata?
optionalmetadata?:Record<string,unknown>
Inherited from
CacheSetOptions.metadata
skipCache?
optionalskipCache?:boolean
tags?
optionaltags?:string[]
Inherited from
CacheSetOptions.tags
ttlSeconds?
optionalttlSeconds?:number
Inherited from
CacheSetOptions.ttlSeconds
Interface: CacheSetOptions
Extended by
CachePolicy
Properties
metadata?
optionalmetadata?:Record<string,unknown>
tags?
optionaltags?:string[]
ttlSeconds?
optionalttlSeconds?:number
Type Alias: CacheKeyPart
CacheKeyPart =
string|number|boolean|null|undefined|Record<string,unknown> | (Record<string,unknown> |string|number|boolean|null|undefined)[]
Cache-related types for the PerspectAPI SDK.
Class: CacheManager
Constructors
Constructor
new CacheManager(
config?):CacheManager
Parameters
config?
CacheConfig
Returns
CacheManager
Methods
buildKey()
buildKey(
parts):string
Parameters
parts
CacheKeyPart[]
Returns
string
delete()
delete(
key):Promise<void>
Parameters
key
string
Returns
Promise<void>
getKeyPrefix()
getKeyPrefix():
string
Returns
string
getOrSet()
getOrSet<
T>(key,resolveValue,policy?):Promise<T>
Type Parameters
T
T
Parameters
key
string
resolveValue
() => Promise<T>
policy?
CachePolicy
Returns
Promise<T>
invalidate()
invalidate(
options):Promise<void>
Parameters
options
CacheInvalidateOptions
Returns
Promise<void>
isEnabled()
isEnabled():
boolean
Returns
boolean
set()
set<
T>(key,value,options?):Promise<void>
Type Parameters
T
T
Parameters
key
string
value
T
options?
CacheSetOptions
Returns
Promise<void>
Class: CloudflareKVCacheAdapter
Implements
CacheAdapter
Constructors
Constructor
new CloudflareKVCacheAdapter(
kv):CloudflareKVCacheAdapter
Parameters
kv
KVLike
Returns
CloudflareKVCacheAdapter
Methods
clear()
clear():
Promise<void>
Optional clear method to wipe all entries for adapters that manage isolated namespaces.
Returns
Promise<void>
Implementation of
CacheAdapter.clear
delete()
delete(
key):Promise<void>
Remove a cached entry.
Parameters
key
string
Returns
Promise<void>
Implementation of
CacheAdapter.delete
deleteMany()
deleteMany(
keys):Promise<void>
Optional bulk delete implementation.
Parameters
keys
string[]
Returns
Promise<void>
Implementation of
CacheAdapter.deleteMany
get()
get(
key):Promise<string|null>
Retrieve a raw cache payload for the given key. Implementations should return undefined (or null) when the key does not exist or has expired.
Parameters
key
string
Returns
Promise<string | null>
Implementation of
CacheAdapter.get
set()
set(
key,value,options?):Promise<void>
Store a raw payload for the given key. Implementations MAY honour ttlSeconds natively; the cache manager will also persist expiry timestamps in the payload for adapters that do not have native TTL support.
Parameters
key
string
value
string
options?
ttlSeconds?
number
Returns
Promise<void>
Implementation of
CacheAdapter.set
Class: InMemoryCacheAdapter
Implements
CacheAdapter
Constructors
Constructor
new InMemoryCacheAdapter():
InMemoryCacheAdapter
Returns
InMemoryCacheAdapter
Methods
clear()
clear():
Promise<void>
Optional clear method to wipe all entries for adapters that manage isolated namespaces.
Returns
Promise<void>
Implementation of
CacheAdapter.clear
delete()
delete(
key):Promise<void>
Remove a cached entry.
Parameters
key
string
Returns
Promise<void>
Implementation of
CacheAdapter.delete
deleteMany()
deleteMany(
keys):Promise<void>
Optional bulk delete implementation.
Parameters
keys
string[]
Returns
Promise<void>
Implementation of
CacheAdapter.deleteMany
get()
get(
key):Promise<string|undefined>
Retrieve a raw cache payload for the given key. Implementations should return undefined (or null) when the key does not exist or has expired.
Parameters
key
string
Returns
Promise<string | undefined>
Implementation of
CacheAdapter.get
set()
set(
key,value,options?):Promise<void>
Store a raw payload for the given key. Implementations MAY honour ttlSeconds natively; the cache manager will also persist expiry timestamps in the payload for adapters that do not have native TTL support.
Parameters
key
string
value
string
options?
ttlSeconds?
number
Returns
Promise<void>
Implementation of
CacheAdapter.set
Class: NoopCacheAdapter
Implements
CacheAdapter
Constructors
Constructor
new NoopCacheAdapter():
NoopCacheAdapter
Returns
NoopCacheAdapter
Methods
clear()
clear():
Promise<void>
Optional clear method to wipe all entries for adapters that manage isolated namespaces.
Returns
Promise<void>
Implementation of
CacheAdapter.clear
delete()
delete():
Promise<void>
Remove a cached entry.
Returns
Promise<void>
Implementation of
CacheAdapter.delete
deleteMany()
deleteMany():
Promise<void>
Optional bulk delete implementation.
Returns
Promise<void>
Implementation of
CacheAdapter.deleteMany
get()
get():
Promise<undefined>
Retrieve a raw cache payload for the given key. Implementations should return undefined (or null) when the key does not exist or has expired.
Returns
Promise<undefined>
Implementation of
CacheAdapter.get
set()
set():
Promise<void>
Store a raw payload for the given key. Implementations MAY honour ttlSeconds natively; the cache manager will also persist expiry timestamps in the payload for adapters that do not have native TTL support.
Returns
Promise<void>
Implementation of
CacheAdapter.set