@PostgreSQL-Typed/Cache
A PostgreSQL-Typed extension to cache queries using Keyv
Table of Contents
Installation
Usage
Ecosystem
License
Installation
Install @postgresql-typed/cache
(keyv is a dependency of this package, so you don't need to install it)
npm install --save @postgresql-typed/cache
By default Keyv will store everything in memory, you can optionally also install a storage adapter.
npm install --save @keyv/redis
npm install --save @keyv/mongo
npm install --save @keyv/sqlite
npm install --save @keyv/postgres
npm install --save @keyv/mysql
npm install --save @keyv/etcd
Usage
Add the Cache extension to the core.extensions
array in your PostgreSQL-Typed configuration.
And set any options you want to use in the cache
object.
(All options are optional, and will use the default values if not set)
import { defineConfig } from "@postgresql-typed/cli/config";
import "@postgresql-typed/cache/register"
export default defineConfig({
core: {
extensions: [
"@postgresql-typed/cache",
],
},
cache: {
uri: process.env.CACHE_URI,
namespace: "my-namespace"
ttl: 1000 * 60 * 15,
types: ["select", "insert", "update", "delete"];
}
});
Ecosystem
This package is part of the PostgreSQL-Typed ecosystem.
License
Mozilla Public License 2.0