JSPM

@ioki/node-ts-cache-storage-ioredis

8.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q15799F
  • License MIT

Redis storage module for node-ts-cache

Package Exports

  • @ioki/node-ts-cache-storage-ioredis
  • @ioki/node-ts-cache-storage-ioredis/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ioki/node-ts-cache-storage-ioredis) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-ts-cache-storage-ioredis

IoRedis storage module for node-ts-cache.

An IoRedis instance must be created and passed to the library. See https://github.com/luin/ioredis#connect-to-redis for available options.

yarn add @ioki/node-ts-cache @ioki/node-ts-cache-storage-ioredis ioredis
import { Cache, CacheContainer } from "@ioki/node-ts-cache"
import { IoRedisStorage } from "@ioki/node-ts-cache-storage-ioredis"
import IoRedis from "ioredis"

const ioRedisInstance = new IoRedis({
    port: 6379, // Redis port
    host: "127.0.0.1", // Redis host
    family: 4, // 4 (IPv4) or 6 (IPv6)
    password: "auth",
    db: 0
})
const userCache = new CacheContainer(new IoRedisStorage(ioRedisInstance))

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