@hile/cache 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/define.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export declare class Cache<R> {
2
2
  readonly data: R;
3
3
  private _expire;
4
+ readonly __$flag__ = "cache";
4
5
  constructor(data: R);
5
6
  setExpire(seconds: number): this;
6
7
  get expire(): number;
package/dist/define.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export class Cache {
2
2
  data;
3
3
  _expire = 0; // 0: 永不过期
4
+ __$flag__ = 'cache';
4
5
  constructor(data) {
5
6
  this.data = data;
6
7
  }
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { Cache } from './define.js';
2
1
  export * from './define.js';
3
2
  export class RedisCache {
4
3
  prefix;
@@ -14,7 +13,7 @@ export class RedisCache {
14
13
  async _write(target, params) {
15
14
  const key = this.makeKey(target.key, params);
16
15
  const cache = await target.fn(params);
17
- if (!(cache instanceof Cache)) {
16
+ if (cache.__$flag__ !== 'cache') {
18
17
  throw new Error('Cache result must be an instance of Cache');
19
18
  }
20
19
  const redis = this.redis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hile/cache",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -23,5 +23,5 @@
23
23
  "dependencies": {
24
24
  "ioredis": "^5.11.0"
25
25
  },
26
- "gitHead": "9f8e7074872709eccd3cac128999f872521b061e"
26
+ "gitHead": "2d8091212ef354336c03e346d6fd49b6b335a780"
27
27
  }