@coolgk/cache
Advanced tools
Comparing version 1.0.6 to 1.0.8
/*! | ||
* @package @coolgk/utils | ||
* @version 1.0.6 | ||
* @version 1.0.8 | ||
* @link https://www.npmjs.com/package/@coolgk/utils | ||
@@ -20,2 +20,3 @@ * @license MIT | ||
get(name: string): Promise<{}>; | ||
delete(name: string | string[]): Promise<{}>; | ||
getSetIfNull(name: string, callback: () => any, expiry?: number): Promise<{}>; | ||
@@ -22,0 +23,0 @@ command(command: string, ...params: any[]): Promise<any>; |
/*! | ||
* @package @coolgk/utils | ||
* @version 1.0.6 | ||
* @version 1.0.8 | ||
* @link https://www.npmjs.com/package/@coolgk/utils | ||
@@ -19,6 +19,7 @@ * @license MIT | ||
get(name) { | ||
return this.command('get', name).then((value) => { | ||
return Promise.resolve(JSON.parse(value)); | ||
}); | ||
return this.command('get', name).then((value) => JSON.parse(value)); | ||
} | ||
delete(name) { | ||
return this.command('del', name); | ||
} | ||
getSetIfNull(name, callback, expiry = 0) { | ||
@@ -25,0 +26,0 @@ return this.get(name).then((cachedValue) => { |
@@ -1,1 +0,1 @@ | ||
{"name":"@coolgk/cache","version":"1.0.6","author":"Daniel Gong <daniel.k.gong@gmail.com>","homepage":"https://www.npmjs.com/package/@coolgk/utils","bugs":{"url":"https://github.com/coolgk/utils/issues"},"repository":{"type":"git","url":"https://github.com/coolgk/utils.git"},"description":"a redis wrapper","keywords":["redis","cache","typescript"],"dependencies":{"@types/redis":"^2.8.3","redis":"^2.8.0"},"pre-commit":{"silent":false,"run":["test:precommit","tslint"]},"main":"./cache.js","types":"./cache.d.ts","license":"MIT"} | ||
{"name":"@coolgk/cache","version":"1.0.8","author":"Daniel Gong <daniel.k.gong@gmail.com>","homepage":"https://www.npmjs.com/package/@coolgk/utils","bugs":{"url":"https://github.com/coolgk/utils/issues"},"repository":{"type":"git","url":"https://github.com/coolgk/utils.git"},"description":"a redis wrapper","keywords":["redis","cache","typescript"],"dependencies":{"@types/redis":"^2.8.3","redis":"^2.8.0"},"pre-commit":{"silent":false,"run":["test:precommit","tslint"]},"main":"./cache.js","types":"./cache.d.ts","license":"MIT"} |
@@ -43,2 +43,26 @@ | ||
Promise.all([ | ||
cache.set('x', 'val x'), | ||
cache.set('y', 'val y'), | ||
cache.set('z', 'val z') | ||
]).then( | ||
() => Promise.all([ | ||
cache.get('x').then(console.log), // val x | ||
cache.get('y').then(console.log), // val y | ||
cache.get('z').then(console.log) // val z | ||
]) | ||
).then( | ||
() => Promise.all([ | ||
cache.delete('x'), | ||
cache.delete('y'), | ||
cache.delete('z') | ||
]) | ||
).then( | ||
() => Promise.all([ | ||
cache.get('x').then(console.log), // null | ||
cache.get('y').then(console.log), // null | ||
cache.get('z').then(console.log) // null | ||
]) | ||
); | ||
``` | ||
@@ -54,2 +78,3 @@ <a name="Cache"></a> | ||
* [.get(name)](#Cache+get) ⇒ <code>promise</code> | ||
* [.delete(name)](#Cache+delete) ⇒ <code>promise</code> | ||
* [.getSetIfNull(name, callback, [expiry])](#Cache+getSetIfNull) ⇒ <code>promise</code> | ||
@@ -87,2 +112,11 @@ * [.command(command, ...params)](#Cache+command) ⇒ <code>promise</code> | ||
<a name="Cache+delete"></a> | ||
### cache.delete(name) ⇒ <code>promise</code> | ||
**Kind**: instance method of [<code>Cache</code>](#Cache) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> \| <code>Array.<string></code> | name(s) of the variable | | ||
<a name="Cache+getSetIfNull"></a> | ||
@@ -89,0 +123,0 @@ |
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
6644
64
142