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

cache-manager-ioredis-yet

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-manager-ioredis-yet - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

6

CHANGELOG.md
### Changelog
## 1.0.1 (2022-11-2022)
## 1.0.2 (2022-12-21)
- Fixes ttl in milliseconds
## 1.0.1 (2022-11-02)
- Fixes support for redis cluster

@@ -6,0 +10,0 @@

2

dist/index.d.ts
import Redis, { Cluster, ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
import type { Cache, Store, Config } from 'cache-manager';
export declare type RedisCache = Cache<RedisStore>;
export type RedisCache = Cache<RedisStore>;
export interface RedisStore extends Store {

@@ -5,0 +5,0 @@ readonly isCacheable: (value: unknown) => boolean;

@@ -36,3 +36,3 @@ "use strict";

if (t)
yield redisCache.setex(key, t, getVal(value));
yield redisCache.setex(key, Math.trunc(t / 1000), getVal(value));
else

@@ -50,3 +50,3 @@ yield redisCache.set(key, getVal(value));

throw new Error(`"${getVal(value)}" is not a cacheable value`);
multi.setex(key, t / 1000, getVal(value));
multi.setex(key, Math.trunc(t / 1000), getVal(value));
}

@@ -53,0 +53,0 @@ yield multi.exec();

@@ -14,3 +14,3 @@ {

"description": "Redis store for node-cache-manager updated",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -34,20 +34,20 @@ "main": "dist/index.js",

"devDependencies": {
"@commitlint/cli": "17.2.0",
"@commitlint/config-conventional": "17.2.0",
"@commitlint/cli": "17.3.0",
"@commitlint/config-conventional": "17.3.0",
"@release-it/conventional-changelog": "5.1.1",
"@types/node": "18.11.9",
"@typescript-eslint/eslint-plugin": "5.42.0",
"@typescript-eslint/parser": "5.42.0",
"@vitest/coverage-c8": "0.24.5",
"@types/node": "18.11.17",
"@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.47.0",
"@vitest/coverage-c8": "0.26.2",
"c8": "7.12.0",
"dotenv-cli": "6.0.0",
"eslint": "8.26.0",
"eslint": "8.30.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "8.0.1",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"release-it": "15.5.0",
"typescript": "4.8.4",
"vitest": "0.24.5"
"husky": "8.0.2",
"lint-staged": "13.1.0",
"prettier": "2.8.1",
"release-it": "15.5.1",
"typescript": "4.9.4",
"vitest": "0.26.2"
},

@@ -54,0 +54,0 @@ "engines": {

@@ -38,3 +38,3 @@ import Redis, {

const t = ttl === undefined ? options?.ttl : ttl;
if (t) await redisCache.setex(key, t, getVal(value));
if (t) await redisCache.setex(key, Math.trunc(t / 1000), getVal(value));
else await redisCache.set(key, getVal(value));

@@ -49,3 +49,3 @@ },

throw new Error(`"${getVal(value)}" is not a cacheable value`);
multi.setex(key, t / 1000, getVal(value));
multi.setex(key, Math.trunc(t / 1000), getVal(value));
}

@@ -52,0 +52,0 @@ await multi.exec();

@@ -56,2 +56,8 @@ import { describe, expect, it, beforeEach } from 'vitest';

it('should store a value with a specific ttl', async () => {
await expect(redisCache.set('foo', 'bar', 1000)).resolves.toBeUndefined();
await new Promise((resolve) => setTimeout(resolve, 2000));
await expect(redisCache.get('foo')).resolves.toBeUndefined();
});
it('should not be able to store a null value (not cacheable)', () =>

@@ -217,5 +223,5 @@ expect(redisCache.set('foo2', null)).rejects.toBeDefined());

it('should retrieve ttl for a given key', async () => {
const ttl = 100;
const ttl = 1000;
await redisCache.set('foo', 'bar', ttl);
await expect(redisCache.store.ttl('foo')).resolves.toEqual(ttl);
await expect(redisCache.store.ttl('foo')).resolves.toEqual(ttl / 1000);

@@ -222,0 +228,0 @@ await redisCache.set('foo', 'bar', 0);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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