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

mikro-orm-cache-adapter-redis

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mikro-orm-cache-adapter-redis - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

27

dist/index.cjs.js

@@ -78,3 +78,5 @@ 'use strict';

function RedisCacheAdapter(options) {
var _a = options.debug, debug = _a === void 0 ? false : _a, expiration = options.expiration, keyPrefix = options.keyPrefix;
var _a;
var _b = options.debug, debug = _b === void 0 ? false : _b, expiration = options.expiration, keyPrefix = options.keyPrefix;
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : console.log;
this.keyPrefix = keyPrefix || "mikro";

@@ -86,3 +88,3 @@ if (options.client) {

var redisOpt = __rest(options, []);
this.client = new IORedis__default['default'](redisOpt);
this.client = new IORedis__default["default"](redisOpt);
}

@@ -92,8 +94,9 @@ this.debug = debug;

if (this.debug) {
console.log("redis client created!", this.expiration);
this.logger("The Redis client for cache has been created! | Cache expiration: ".concat(this.expiration, "ms"));
}
}
RedisCacheAdapter.prototype._getKey = function (name) {
return this.keyPrefix + ":" + name;
return "".concat(this.keyPrefix, ":").concat(name);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RedisCacheAdapter.prototype.get = function (key) {

@@ -110,3 +113,3 @@ return __awaiter(this, void 0, void 0, function () {

if (this.debug) {
console.log("get \"" + completKey + "\": \"" + data + "\"");
this.logger("Get \"".concat(completKey, "\": \"").concat(data, "\""));
}

@@ -120,3 +123,5 @@ if (!data)

};
RedisCacheAdapter.prototype.set = function (key, data, origin, expiration) {
RedisCacheAdapter.prototype.set = function (key,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data, _origin, expiration) {
if (expiration === void 0) { expiration = this.expiration; }

@@ -131,3 +136,3 @@ return __awaiter(this, void 0, void 0, function () {

if (this.debug) {
console.log("set \"" + completeKey + "\": \"" + stringData + "\" with expiration " + expiration);
this.logger("Set \"".concat(completeKey, "\": \"").concat(stringData, "\" with cache expiration ").concat(expiration, "ms"));
}

@@ -168,7 +173,7 @@ if (!expiration) return [3 /*break*/, 2];

if (this.debug) {
console.log("clearing cache...");
this.logger("Clearing cache...");
}
return [2 /*return*/, new Promise(function (resolve, reject) {
var stream = _this.client.scanStream({
match: _this.keyPrefix + ":*",
match: "".concat(_this.keyPrefix, ":*"),
});

@@ -187,3 +192,3 @@ var pipeline = _this.client.pipeline();

if (_this.debug) {
console.log("Error clearing cache");
_this.logger("Error clearing cache");
}

@@ -193,3 +198,3 @@ return reject(err);

if (_this.debug) {
console.log("cleared cache");
_this.logger("Cleared cache");
}

@@ -196,0 +201,0 @@ resolve();

@@ -70,3 +70,5 @@ import IORedis from 'ioredis';

function RedisCacheAdapter(options) {
var _a = options.debug, debug = _a === void 0 ? false : _a, expiration = options.expiration, keyPrefix = options.keyPrefix;
var _a;
var _b = options.debug, debug = _b === void 0 ? false : _b, expiration = options.expiration, keyPrefix = options.keyPrefix;
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : console.log;
this.keyPrefix = keyPrefix || "mikro";

@@ -83,8 +85,9 @@ if (options.client) {

if (this.debug) {
console.log("redis client created!", this.expiration);
this.logger("The Redis client for cache has been created! | Cache expiration: ".concat(this.expiration, "ms"));
}
}
RedisCacheAdapter.prototype._getKey = function (name) {
return this.keyPrefix + ":" + name;
return "".concat(this.keyPrefix, ":").concat(name);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RedisCacheAdapter.prototype.get = function (key) {

@@ -101,3 +104,3 @@ return __awaiter(this, void 0, void 0, function () {

if (this.debug) {
console.log("get \"" + completKey + "\": \"" + data + "\"");
this.logger("Get \"".concat(completKey, "\": \"").concat(data, "\""));
}

@@ -111,3 +114,5 @@ if (!data)

};
RedisCacheAdapter.prototype.set = function (key, data, origin, expiration) {
RedisCacheAdapter.prototype.set = function (key,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data, _origin, expiration) {
if (expiration === void 0) { expiration = this.expiration; }

@@ -122,3 +127,3 @@ return __awaiter(this, void 0, void 0, function () {

if (this.debug) {
console.log("set \"" + completeKey + "\": \"" + stringData + "\" with expiration " + expiration);
this.logger("Set \"".concat(completeKey, "\": \"").concat(stringData, "\" with cache expiration ").concat(expiration, "ms"));
}

@@ -159,7 +164,7 @@ if (!expiration) return [3 /*break*/, 2];

if (this.debug) {
console.log("clearing cache...");
this.logger("Clearing cache...");
}
return [2 /*return*/, new Promise(function (resolve, reject) {
var stream = _this.client.scanStream({
match: _this.keyPrefix + ":*",
match: "".concat(_this.keyPrefix, ":*"),
});

@@ -178,3 +183,3 @@ var pipeline = _this.client.pipeline();

if (_this.debug) {
console.log("Error clearing cache");
_this.logger("Error clearing cache");
}

@@ -184,3 +189,3 @@ return reject(err);

if (_this.debug) {
console.log("cleared cache");
_this.logger("Cleared cache");
}

@@ -187,0 +192,0 @@ resolve();

@@ -5,2 +5,3 @@ import type { CacheAdapter } from "@mikro-orm/core";

expiration?: number;
keyPrefix?: string;
debug?: boolean;

@@ -12,3 +13,3 @@ }

client: Redis;
keyPrefix?: string;
logger: (...args: unknown[]) => void;
}

@@ -21,6 +22,7 @@ export declare type RedisCacheAdapterOptions = BuildOptions | ClientOptions;

private readonly keyPrefix;
private readonly logger;
constructor(options: RedisCacheAdapterOptions);
_getKey(name: string): string;
get<T = any>(key: string): Promise<T | undefined>;
set(key: string, data: any, origin: string, expiration?: number | undefined): Promise<void>;
set(key: string, data: any, _origin: string, expiration?: number | undefined): Promise<void>;
remove(name: string): Promise<void>;

@@ -27,0 +29,0 @@ clear(): Promise<void>;

{
"name": "mikro-orm-cache-adapter-redis",
"version": "3.1.0",
"version": "3.2.0",
"description": "A redis cache adapter for mikro-orm",

@@ -14,3 +14,4 @@ "main": "dist/index.cjs.js",

"build": "rollup -c --environment NODE_ENV:production",
"build-watch": "rollup -c --environment NODE_ENV:production -w --no-watch.clearScreen"
"build-watch": "rollup -c --environment NODE_ENV:production -w --no-watch.clearScreen",
"test": "eslint ."
},

@@ -22,3 +23,9 @@ "dependencies": {

"@mikro-orm/core": "^5.0.5",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"ioredis": "^4.24.4",
"prettier": "2.6.0",
"rollup": "^2.42.4",

@@ -25,0 +32,0 @@ "rollup-plugin-typescript2": "^0.30.0",

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