@appolo/cache
Advanced tools
Comparing version 0.0.3 to 0.0.34
@@ -28,2 +28,15 @@ "use strict"; | ||
} | ||
async del(...args) { | ||
let key = this._getKey(args); | ||
this._cache.del(key); | ||
if (this._options.db) { | ||
let redisKey = this._getRedisKey(key); | ||
await this.redisProvider.del(redisKey); | ||
} | ||
} | ||
async set(value, ...args) { | ||
let key = this._getKey(args); | ||
this._setMemoryValue(key, value); | ||
await this._setRedisValue(key, value); | ||
} | ||
_getSync(args, key) { | ||
@@ -132,3 +145,3 @@ let item = this._getValueFromMemory(args, key); | ||
let redisKey = this._getRedisKey(key), age = this._getRedisMaxAge(); | ||
(this._options.maxAge ? this.redisProvider.setWithExpire(redisKey, value, age) : this.redisProvider.set(redisKey, value)) | ||
return (this._options.maxAge ? this.redisProvider.setWithExpire(redisKey, value, age) : this.redisProvider.set(redisKey, value)) | ||
.catch(e => this.logger.error(`failed to set redis cache ${key}`, { e })); | ||
@@ -135,0 +148,0 @@ } |
@@ -48,2 +48,22 @@ import {define, initMethod, inject, injectLazy} from 'appolo'; | ||
public async del(...args: any[]): Promise<void> { | ||
let key = this._getKey(args); | ||
this._cache.del(key); | ||
if (this._options.db) { | ||
let redisKey = this._getRedisKey(key); | ||
await this.redisProvider.del(redisKey); | ||
} | ||
} | ||
public async set(value: any, ...args: any[]): Promise<void> { | ||
let key = this._getKey(args); | ||
this._setMemoryValue(key, value); | ||
await this._setRedisValue(key, value); | ||
} | ||
private _getSync(args: any[], key: string) { | ||
@@ -199,3 +219,3 @@ | ||
(this._options.maxAge ? this.redisProvider.setWithExpire(redisKey, value, age) : this.redisProvider.set(redisKey, value)) | ||
return (this._options.maxAge ? this.redisProvider.setWithExpire(redisKey, value, age) : this.redisProvider.set(redisKey, value)) | ||
.catch(e => this.logger.error(`failed to set redis cache ${key}`, {e})) | ||
@@ -202,0 +222,0 @@ |
{ | ||
"name": "@appolo/cache", | ||
"version": "0.0.3", | ||
"version": "0.0.34", | ||
"description": "appolo cache module", | ||
@@ -14,4 +14,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@appolo/logger": "0.0.14", | ||
"@appolo/redis": "0.0.1", | ||
"@appolo/logger": "^0.0.14", | ||
"@appolo/redis": "^0.0.2", | ||
"appolo": "^6.0.59", | ||
@@ -18,0 +18,0 @@ "bluebird": "^3.5.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34184
846
+ Added@appolo/redis@0.0.2(transitive)
- Removed@appolo/redis@0.0.1(transitive)
Updated@appolo/logger@^0.0.14
Updated@appolo/redis@^0.0.2