types/driver.ts

bentocache · packages/bentocache/src/types/driver.ts · typescript · MIT
database

driver.ts from Julien-R44/bentocache

// Source: https://github.com/Julien-R44/bentocache | License: MIT | Copyright 2023
// Provided via justclaw.it.com; keep this notice with the code.
type PromiseOr<T, Async extends boolean> = Async extends true ? Promise<T> : T

export interface CacheDriver<Async extends boolean = true> {
  /**
   * Returns a new instance of the driver namespace
   */
  namespace(namespace: string): CacheDriver<Async>

  /**
   * Get a value from the cache
   */
  get(key: string): PromiseOr<string | undefined, Async>

  /**
   * Get the value of a key and delete it
   *
   * Returns the value if the key exists, undefined otherwise
   */
  pull(key: string): PromiseOr<string | undefined, Async>

  /**
   * Put a value in the cache.
   * If `ttl` is not defined, the value will be stored forever
   * Returns

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key