import { JsonValue } from '@backstage/types'; /** * Options passed to {@link CacheService.set}. * * @public */ export type CacheServiceSetOptions = { /** * Optional TTL in milliseconds. Defaults to the TTL provided when the client * was set up (or no TTL if none are provided). */ ttl?: number; }; /** * Options passed to {@link CacheService.withOptions}. * * @public */ export type CacheServiceOptions = { /** * An optional default TTL (in milliseconds) to be set when getting a client * instance. If not provided, data will persist indefinitely by default (or * can be configured per entry at set-time). */ defaultTtl?: number; }; /** * A pre-configured, storage agnostic cache service suitable for use by * Backstage plugins. * * @public */ export interface CacheService { /** * Reads data from a cache store for the given key. If no data was found, * returns undefined. */ get(key: string): Promise; /** * Writes the given data to a cache store, associated with the given key. An * optional TTL may also be provided, otherwise it defaults to the TTL that * was provided when the client was instantiated. */ set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise; /** * Removes the given key from the cache store. */ delete(key: string): Promise; /** * Creates a new {@link CacheService} instance with the given options. */ withOptions(options: CacheServiceOptions): CacheService; }