This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@boredland/node-ts-cache-storage-pg
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

node-ts-cache-storage-pg

Postgres storage module for node-ts-cache.

This module is driver-agnostic. It expects you to bring your own raw query method - something most of the postgres drivers will provide.

yarn add @boredland/node-ts-cache @boredland/node-ts-cache-storage-pg

In this example, node-postgres (pg) is being used. You should to provide a table with the following columns:

* key: text
value: jsonb

The query function should return an array of objects: { key: string, value: CacheItem }[].

import { PgStorage } from "@boredland/node-ts-cache-storage-pg"
import { Cache, CacheContainer } from "@boredland/node-ts-cache"
import Client from "pg"

const client = new Client()

await client.connect()

const storage = new PgStorage(tableName, async (query) => (await new Client().query(query)).rows)

const userCache = new CacheContainer(storage)

class MyService {
    @Cache(userCache, { ttl: 60 })
    public async getUsers(): Promise<string[]> {
        return ["Max", "User"]
    }
}

Package Sidebar

Install

npm i @boredland/node-ts-cache-storage-pg

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

7.35 kB

Total Files

10

Last publish

Collaborators

  • jonasstr