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

@nestjs/cache-manager

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/cache-manager

Nest - modern, fast, powerful node.js web framework (@cache-manager)

  • 2.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
340K
decreased by-49.6%
Maintainers
2
Weekly downloads
 
Created

What is @nestjs/cache-manager?

@nestjs/cache-manager is a caching module for the NestJS framework that provides a simple and efficient way to manage caching in your application. It supports various caching stores and strategies, making it flexible and powerful for different use cases.

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

Basic Caching

This feature allows you to set up basic caching in your NestJS application. You can configure the time-to-live (ttl) and the maximum number of items in the cache.

const { CacheModule } = require('@nestjs/cache-manager');
const { Module } = require('@nestjs/common');

@Module({
  imports: [
    CacheModule.register({
      ttl: 5, // seconds
      max: 10, // maximum number of items in cache
    }),
  ],
})
export class AppModule {}

Using Cache Interceptors

This feature demonstrates how to use cache interceptors to automatically cache the response of a controller method. This can be useful for reducing the load on your server by caching frequently requested data.

const { CacheInterceptor, CacheModule } = require('@nestjs/cache-manager');
const { Controller, Get, UseInterceptors } = require('@nestjs/common');

@Controller('cats')
@UseInterceptors(CacheInterceptor)
export class CatsController {
  @Get()
  findAll() {
    return [{ name: 'Tom' }, { name: 'Jerry' }];
  }
}

Custom Cache Store

This feature allows you to use a custom cache store, such as Redis, for your caching needs. This can be useful for distributed caching scenarios where you need a more robust and scalable caching solution.

const { CacheModule } = require('@nestjs/cache-manager');
const { Module } = require('@nestjs/common');
const * as redisStore from 'cache-manager-redis-store';

@Module({
  imports: [
    CacheModule.register({
      store: redisStore,
      host: 'localhost',
      port: 6379,
    }),
  ],
})
export class AppModule {}

Other packages similar to @nestjs/cache-manager

FAQs

Package last updated on 21 Oct 2024

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