Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/cache-manager

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/cache-manager

TypeScript definitions for cache-manager

  • 4.0.6
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
342K
increased by7.81%
Maintainers
1
Weekly downloads
 
Created

What is @types/cache-manager?

@types/cache-manager provides TypeScript type definitions for the cache-manager library, which is a multi-level caching library that supports various storage engines.

What are @types/cache-manager's main functionalities?

Basic In-Memory Caching

This feature allows you to set up a basic in-memory cache with a specified time-to-live (TTL) and maximum size.

const cacheManager = require('cache-manager');
const memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 10 /* seconds */ });

memoryCache.set('foo', 'bar', { ttl: 10 }, (err) => {
  if (err) throw err;

  memoryCache.get('foo', (err, result) => {
    if (err) throw err;
    console.log(result); // 'bar'
  });
});

Multi-Level Caching

This feature allows you to set up multi-level caching, combining different storage engines like in-memory and Redis.

const cacheManager = require('cache-manager');
const memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 10 });
const redisStore = require('cache-manager-redis-store');
const redisCache = cacheManager.caching({ store: redisStore, host: 'localhost', port: 6379, ttl: 600 });

const multiCache = cacheManager.multiCaching([memoryCache, redisCache]);

multiCache.set('foo', 'bar', { ttl: 10 }, (err) => {
  if (err) throw err;

  multiCache.get('foo', (err, result) => {
    if (err) throw err;
    console.log(result); // 'bar'
  });
});

Custom Store

This feature allows you to create a custom store by defining your own get, set, and delete methods.

const cacheManager = require('cache-manager');
const customStore = {
  get: (key, callback) => {
    // Custom get logic
    callback(null, 'value');
  },
  set: (key, value, options, callback) => {
    // Custom set logic
    callback(null);
  },
  del: (key, callback) => {
    // Custom delete logic
    callback(null);
  }
};

const customCache = cacheManager.caching({ store: customStore });

customCache.set('foo', 'bar', { ttl: 10 }, (err) => {
  if (err) throw err;

  customCache.get('foo', (err, result) => {
    if (err) throw err;
    console.log(result); // 'bar'
  });
});

Other packages similar to @types/cache-manager

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc