🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

cache-manager-redis-yet

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-manager-redis-yet

Redis store for node-cache-manager updated

5.1.5
latest
Version published
Weekly downloads
150K
5.73%
Maintainers
1
Weekly downloads
 
Created

What is cache-manager-redis-yet?

The cache-manager-redis-yet package is a Redis store for the cache-manager module, which allows you to use Redis as a caching layer in your Node.js applications. It provides functionalities for setting, getting, and managing cache entries in a Redis database.

What are cache-manager-redis-yet's main functionalities?

Setting a Cache Value

This feature allows you to set a value in the Redis cache with a specified time-to-live (TTL). The code sample demonstrates how to set up the cache manager with the Redis store and set a cache value.

const cacheManager = require('cache-manager');
const redisStore = require('cache-manager-redis-yet');

const cache = cacheManager.caching({
  store: redisStore,
  host: 'localhost',
  port: 6379,
  ttl: 600
});

cache.set('foo', 'bar', { ttl: 10 }, (err) => {
  if (err) throw err;
  console.log('Value set');
});

Getting a Cache Value

This feature allows you to retrieve a value from the Redis cache. The code sample shows how to get a previously set cache value.

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

Deleting a Cache Value

This feature allows you to delete a value from the Redis cache. The code sample demonstrates how to delete a cache entry.

cache.del('foo', (err) => {
  if (err) throw err;
  console.log('Value deleted');
});

Wrapping a Function

This feature allows you to wrap a function so that its result is cached. The code sample demonstrates how to wrap a function that simulates a long-running operation.

cache.wrap('foo', (cb) => {
  // Simulate a long-running operation
  setTimeout(() => {
    cb(null, 'bar');
  }, 2000);
}, (err, result) => {
  if (err) throw err;
  console.log(result); // 'bar'
});

Other packages similar to cache-manager-redis-yet

FAQs

Package last updated on 23 Sep 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