cache-bottle-dependencies
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

cache-bottle-dependencies

Cache any factory method using a unified config with configurable adapters and ttls.

Installation

npm install cache-bottle-dependencies

Usage

import Bottle from "bottlejs";

import cacheManager from "cache-manager";
import redisStore from "cache-manager-ioredis";

import cacheBottleDependencies from 'cache-bottle-dependencies';

const bottle = new Bottle();

const adapters = {
  redis: cacheManager.caching({
    store: redisStore,
    host: REDIS_HOST,
    ttl: ms(cacheConfig.defaultTtl),
  }),
  memory: cacheManager.caching({
    store: "memory",
    ttl: ms(cacheConfig.defaultTtl),
  }),
};

const config = {
  defaultTtl: "3h",
  defaultAdapter: "redis",
  container: {
    productsRepository.get: {
      ttl: "10m",
      adapter: "memory",
      version: 2,
    },
    productsRepository.list: true,
  },
};

cacheBottleDependencies({ bottle, adapters, config });

Readme

Keywords

Package Sidebar

Install

npm i cache-bottle-dependencies

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

8.03 kB

Total Files

8

Last publish

Collaborators

  • hydrangea