nuxt-multi-cache
Version:
SSR route, component and data cache for Nuxt.js
68 lines (67 loc) • 2.22 kB
TypeScript
export declare class NuxtMultiCacheRouteCacheHelper {
/**
* The collected cache tags.
*/
tags: string[];
/**
* Indicates if the route should be cacheable.
*/
cacheable: boolean | null;
/**
* The maximum age.
*/
maxAge: number | null;
/**
* The stale if error age.
*/
staleIfError: number | null;
/**
* Whether a stale response can be served during revalidation.
*/
staleWhileRevalidate: boolean | null;
/**
* Add cache tags for this route.
*/
addTags(tags?: string[]): NuxtMultiCacheRouteCacheHelper;
/**
* Mark this route as cacheable.
*
* The initial value is null and this method only changes the value if it is
* null. This means that once it's set to uncacheable, there is no way to
* change it back.
*/
setCacheable(): NuxtMultiCacheRouteCacheHelper;
/**
* Mark the route as uncacheable.
*
* After that there is no way to make it cacheable again.
*/
setUncacheable(): NuxtMultiCacheRouteCacheHelper;
/**
* Set a numeric value only if its smaller than the existing value.
*/
setNumeric(property: keyof Pick<NuxtMultiCacheRouteCacheHelper, 'maxAge' | 'staleIfError'>, value: number): NuxtMultiCacheRouteCacheHelper;
/**
* Set the max age in seconds.
*
* The value is only set if it's smaller than the current max age or if it
* hasn't been set yet. The initial value is `null`.
*
* You can always directly set the maxAge property on this object.
*/
setMaxAge(v?: number): NuxtMultiCacheRouteCacheHelper;
/**
* Set the staleIfError in seconds.
*
* If set, then a stale route will be served if that refreshed route throws an error.
*/
setStaleIfError(v?: number): NuxtMultiCacheRouteCacheHelper;
/**
* Sets whether a stale respones can be returned while a new one is being generated.
*/
allowStaleWhileRevalidate(): NuxtMultiCacheRouteCacheHelper;
/**
* Get the expire timestamp as unix epoch (seconds).
*/
getExpires(property: keyof Pick<NuxtMultiCacheRouteCacheHelper, 'maxAge' | 'staleIfError'>): number | undefined;
}