New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 0.1.4 to 0.1.5

4

dist/RedisCacheAdapter.d.ts
import { CacheAdapter } from '@mikro-orm/core';
import { RedisOptions } from 'ioredis';
export interface RedisCacheAdapterOptions extends RedisOptions {
expiration?: number;
debug?: boolean;

@@ -9,6 +10,7 @@ }

private readonly debug;
private readonly expiration?;
constructor(options: RedisCacheAdapterOptions);
get(key: string): Promise<any>;
set(name: string, data: any, origin: string, expiration?: number): Promise<void>;
set(name: string, data: any, origin: string, expiration?: number | undefined): Promise<void>;
clear(): Promise<void>;
}

@@ -57,5 +57,9 @@ "use strict";

function RedisCacheAdapter(options) {
var _a = options.debug, debug = _a === void 0 ? false : _a, redisOpt = __rest(options, ["debug"]);
var _a = options.debug, debug = _a === void 0 ? false : _a, expiration = options.expiration, redisOpt = __rest(options, ["debug", "expiration"]);
this.client = new ioredis_1.default(redisOpt);
this.debug = debug;
this.expiration = expiration;
if (this.debug) {
console.log("redis client created", redisOpt);
}
}

@@ -81,15 +85,18 @@ RedisCacheAdapter.prototype.get = function (key) {

RedisCacheAdapter.prototype.set = function (name, data, origin, expiration) {
if (expiration === void 0) { expiration = this.expiration; }
return __awaiter(this, void 0, void 0, function () {
var stringData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
stringData = JSON.stringify(data);
if (this.debug) {
console.log("set \"" + name + "\": \"" + data + "\" with expiration " + expiration);
console.log("set \"" + name + "\": \"" + stringData + "\" with expiration " + expiration);
}
if (!expiration) return [3 /*break*/, 2];
return [4 /*yield*/, this.client.set(name, JSON.stringify(data), 'PX', expiration)];
return [4 /*yield*/, this.client.set(name, stringData, 'PX', expiration)];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.client.set(name, JSON.stringify(data))];
case 2: return [4 /*yield*/, this.client.set(name, stringData)];
case 3:

@@ -96,0 +103,0 @@ _a.sent();

{
"name": "mikro-orm-cache-adapter-redis",
"version": "0.1.4",
"version": "0.1.5",
"description": "A redis cache adapter for mikro-orm",

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

"prepare": "npm run build",
"build": "tsc"
"build": "tsc",
"build-watch": "tsc -w"
},

@@ -15,0 +16,0 @@ "dependencies": {

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