@amplication/plugin-cache-redis

2.0.5 • Public • Published

@amplication/plugin-cache-redis

NPM Downloads

Use a Redis cache in the service generated by Amplication.

Purpose

This plugin adds the required code to use Redis as a cache in the service generated by Amplication.

It updates the following parts:

  • Adds the required dependencies to package.json.
  • Adds the required environment variables to .env.
  • Adds the CacheModule configured to use Redis to the app.module.ts module imports list.
  • Adds the required service to the docker-compose.yml file.

Configuration

The host setting is the host of the Redis server.

The port setting is the port on which the Redis server is accepting connections.

The ttl setting is the Time To Live for cached values.

The max setting is the maximum amount of requests that can be cached at once.

The username setting is the username used to connect to the server.

The password setting is the password used to connect to the server.

If no configuration is provided the .amplicationrc.json file will use be used as the default values.

{
  "host": "localhost",
  "port": 6379,
  "ttl": 5000,
  "username": null,
  "password": null
}

Scripts

build

Running npm run build will bundle your plugin with Webpack for production.

dev

Running npm run dev will watch your plugin's source code and automatically bundle it with every change.

test

Running npm run test will run the plugin's test suite.

Usage

This plugin provides you with a Redis cache module that you can use in your service as described here: https://docs.nestjs.com/techniques/caching#interacting-with-the-cache-store.

To configure, set the following environment variables:

REDIS_HOST - The host on which the Redis server is running.

REDIS_PORT - The port on which the Redis server is listening.

REDIS_TTL - The default Time To Live, in milliseconds, for cached requests on the Redis server.

REDIS_USERNAME - The username to be used to connect to the Redis server.

REDIS_PASSWORD - The password to be used to connect to the Redis server.

Readme

Keywords

none

Package Sidebar

Install

npm i @amplication/plugin-cache-redis

Weekly Downloads

37,563

Version

2.0.5

License

Apache-2.0

Unpacked Size

4.59 MB

Total Files

19

Last publish

Collaborators

  • amitbarletz
  • amplication-bot
  • barshimi
  • levivannoort
  • morhag
  • mulygottlieb
  • overbit
  • yuvalhazaz