Class LibsqlCacheAdapter<TType>

To utilize the LibsqlCacheAdapter, you must install the "@libsql/client" package and supply a ISerde , with an adapter like SuperJsonSerdeAdapter.

IMPORT_PATH: "@daiso-tech/core/cache/implementations/adapters"

Type Parameters

  • TType = unknown

Implements

Constructors

  • Type Parameters

    • TType = unknown

    Parameters

    Returns LibsqlCacheAdapter<TType>

    import { LibsqlCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
    import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
    import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
    import { createClient } from "@libsql/client";

    (async () => {
    const database = createClient({ url: "file:local.db" });
    const serde = new Serde(new SuperJsonSerdeAdapter());
    const cacheAdapter = new LibsqlCacheAdapter({
    database,
    serde,
    rootGroup: "@global"
    });
    await cacheAdapter.init();
    })();

Methods

  • The put method replaces a key if the key exists including the ttl value or adds key that do not exists with a given ttl. Returns true if the key where replaced otherwise false is returned. You must provide a ttl value. If null is passed, the item will not expire.

    Parameters

    Returns Promise<boolean>