@gibme/cache
    Preparing search index...

    Class DatabaseCache

    Base cache interface

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    client: Database
    defaultTTL: 300

    Accessors

    • get isReady(): Readonly<boolean>

      Returns if the instance is ready

      Returns Readonly<boolean>

    • get type(): string

      Returns string

    Methods

    • Deletes all keys (and values) from the cache

      Returns Promise<boolean>

    • Connects to the database storage

      Returns Promise<void>

    • Deletes the key (including the value) from the cache

      Type Parameters

      • KeyType = any

      Parameters

      Returns Promise<number>

    • Closes the database connection and halts the check interval

      Returns Promise<void>

    • Retrieves the current TTL of the specified key

      Type Parameters

      • KeyType = any

      Parameters

      Returns Promise<undefined | number>

    • Checks if the specified key exists in the cache

      Type Parameters

      • KeyType = any

      Parameters

      Returns Promise<boolean>

    • Mass deletes values with the specified keys

      Type Parameters

      • KeyType = any

      Parameters

      Returns Promise<number>

    • Mass sets values with the specified keys

      Type Parameters

      • ValueType = any
      • KeyType = any

      Parameters

      Returns Promise<boolean>

    • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

      server.on('connection', (stream) => {
      console.log('someone connected!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

      import { EventEmitter } from 'node:events';
      const myEE = new EventEmitter();
      myEE.on('foo', () => console.log('a'));
      myEE.prependListener('foo', () => console.log('b'));
      myEE.emit('foo');
      // Prints:
      // b
      // a

      Parameters

      • event: "set"
      • listener: (key: any, value: any) => void

        The callback function

      Returns this

      v0.1.101

    • Parameters

      • event: "del"
      • listener: (key: any, value: any) => void

      Returns this

    • Parameters

      • event: "flush"
      • listener: () => void

      Returns this

    • Parameters

      • event: "flush_stats"
      • listener: () => void

      Returns this

    • Parameters

      • event: "error"
      • listener: (error: Error) => void

      Returns this

    • Sets the value for the specified key

      Type Parameters

      • ValueType = any
      • KeyType = any

      Parameters

      Returns Promise<boolean>

    • Retrieves the value of the specified key and immediately deletes it from the cache

      Type Parameters

      • ValueType = any
      • KeyType = any

      Parameters

      Returns Promise<undefined | ValueType>

    • Updates the TTL for the specified key

      Type Parameters

      • KeyType = any

      Parameters

      Returns Promise<boolean>