mikro-orm-cache-adapter-redis
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -119,3 +119,3 @@ 'use strict'; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var stringData, completKey; | ||
var stringData, completeKey; | ||
return __generator(this, function (_a) { | ||
@@ -125,12 +125,12 @@ switch (_a.label) { | ||
stringData = JSON.stringify(data); | ||
completKey = this._getKey(key); | ||
completeKey = this._getKey(key); | ||
if (this.debug) { | ||
console.log("set \"" + completKey + "\": \"" + stringData + "\" with expiration " + expiration); | ||
console.log("set \"" + completeKey + "\": \"" + stringData + "\" with expiration " + expiration); | ||
} | ||
if (!expiration) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.client.set(completKey, stringData, "PX", expiration)]; | ||
return [4 /*yield*/, this.client.set(completeKey, stringData, "PX", expiration)]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, this.client.set(completKey, stringData)]; | ||
case 2: return [4 /*yield*/, this.client.set(completeKey, stringData)]; | ||
case 3: | ||
@@ -144,2 +144,17 @@ _a.sent(); | ||
}; | ||
RedisCacheAdapter.prototype.remove = function (name) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var completeKey; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
completeKey = this._getKey(name); | ||
return [4 /*yield*/, this.client.del(completeKey)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
RedisCacheAdapter.prototype.clear = function () { | ||
@@ -194,2 +209,1 @@ return __awaiter(this, void 0, void 0, function () { | ||
exports.RedisCacheAdapter = RedisCacheAdapter; | ||
exports.default = RedisCacheAdapter; |
@@ -1,3 +0,1 @@ | ||
import { RedisCacheAdapter } from './RedisCacheAdapter'; | ||
export * from './RedisCacheAdapter'; | ||
export default RedisCacheAdapter; | ||
export * from "./RedisCacheAdapter"; |
@@ -111,3 +111,3 @@ import IORedis from 'ioredis'; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var stringData, completKey; | ||
var stringData, completeKey; | ||
return __generator(this, function (_a) { | ||
@@ -117,12 +117,12 @@ switch (_a.label) { | ||
stringData = JSON.stringify(data); | ||
completKey = this._getKey(key); | ||
completeKey = this._getKey(key); | ||
if (this.debug) { | ||
console.log("set \"" + completKey + "\": \"" + stringData + "\" with expiration " + expiration); | ||
console.log("set \"" + completeKey + "\": \"" + stringData + "\" with expiration " + expiration); | ||
} | ||
if (!expiration) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.client.set(completKey, stringData, "PX", expiration)]; | ||
return [4 /*yield*/, this.client.set(completeKey, stringData, "PX", expiration)]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, this.client.set(completKey, stringData)]; | ||
case 2: return [4 /*yield*/, this.client.set(completeKey, stringData)]; | ||
case 3: | ||
@@ -136,2 +136,17 @@ _a.sent(); | ||
}; | ||
RedisCacheAdapter.prototype.remove = function (name) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var completeKey; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
completeKey = this._getKey(name); | ||
return [4 /*yield*/, this.client.del(completeKey)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
RedisCacheAdapter.prototype.clear = function () { | ||
@@ -185,3 +200,2 @@ return __awaiter(this, void 0, void 0, function () { | ||
export default RedisCacheAdapter; | ||
export { RedisCacheAdapter }; |
@@ -23,4 +23,6 @@ import type { CacheAdapter } from "@mikro-orm/core"; | ||
set(key: string, data: any, origin: string, expiration?: number | undefined): Promise<void>; | ||
remove(name: string): Promise<void>; | ||
clear(): Promise<void>; | ||
close(): Promise<void>; | ||
} | ||
export default RedisCacheAdapter; |
{ | ||
"name": "mikro-orm-cache-adapter-redis", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "A redis cache adapter for mikro-orm", | ||
@@ -20,3 +20,3 @@ "main": "dist/index.cjs.js", | ||
"devDependencies": { | ||
"@mikro-orm/core": "^4.5.0", | ||
"@mikro-orm/core": "^5.0.5", | ||
"ioredis": "^4.24.4", | ||
@@ -23,0 +23,0 @@ "rollup": "^2.42.4", |
@@ -22,5 +22,10 @@ # Mikro-orm - Redis cache adapter | ||
options: { | ||
// Base options | ||
// An optional key prefix. By default is `mikro` | ||
keyPrefix: 'mikro' | ||
// Here goes IORedis connection options | ||
// Optional: print debug informations | ||
debug: false, | ||
// Here goes IORedis connection options (the library will instantiate the client) | ||
host: '...', | ||
@@ -37,2 +42,3 @@ port: 6379, | ||
```js | ||
import { RedisCacheAdapter } from "mikro-orm-cache-adapter-redis"; | ||
import Redis from "ioredis"; | ||
@@ -39,0 +45,0 @@ |
23520
8
410
56