import { KyselyCacheAdapter } from "@daiso-tech/core/cache/kysely-cache-adapter";
import { Serde } from "@daiso-tech/core/serde";
import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/super-json-serde-adapter"
import SQLite from 'better-sqlite3'
import { Kysely, SqliteDialect } from 'kysely'
const serde = new Serde(new SuperJsonSerdeAdapter());
const cacheAdapter = new KyselyCacheAdapter({
kysely: new Kysely({
dialect: new SqliteDialect({
database: new Sqlite("local.db"),
}),
}),
serde,
});
// You need initialize the adapter once before using it.
await cacheAdapter.init();
To utilize the
KyselyCacheAdapter, you must install the"kysely"package and configure aKyselyclass instance. The adapter have been tested withsqlite,postgresandmysqldatabases.IMPORT_PATH:
"@daiso-tech/core/cache/kysely-cache-adapter"