Socket
Socket
Sign inDemoInstall

@nestjs/cache-manager

Package Overview
Dependencies
17
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nestjs/cache-manager

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


Version published
Weekly downloads
500K
decreased by-0.5%
Maintainers
2
Install size
25.5 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads Coverage Discord Backers on Open Collective Sponsors on Open Collective

Description

cache-manager module for Nest originally published as part of the @nestjs/common package. This package is a drop-in replacement for the deprecated CacheModule.

Installation

$ npm i --save @nestjs/cache-manager cache-manager

Quick Start

Overview & Tutorial

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

FAQs

Last updated on 05 Apr 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc