@tsed/platform-cache 7.35.0-beta.5 → 7.35.0

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.
Files changed (35) hide show
  1. package/jest.config.js +1 -1
  2. package/lib/cjs/index.js +3 -0
  3. package/lib/cjs/index.js.map +1 -1
  4. package/lib/cjs/interceptors/PlatformCacheInterceptor.js +18 -12
  5. package/lib/cjs/interceptors/PlatformCacheInterceptor.js.map +1 -1
  6. package/lib/cjs/services/PlatformCache.js +20 -6
  7. package/lib/cjs/services/PlatformCache.js.map +1 -1
  8. package/lib/cjs/utils/getInterceptorOptions.js +10 -0
  9. package/lib/cjs/utils/getInterceptorOptions.js.map +1 -0
  10. package/lib/cjs/utils/getPrefix.js +14 -0
  11. package/lib/cjs/utils/getPrefix.js.map +1 -0
  12. package/lib/cjs/utils/isEndpoint.js +10 -0
  13. package/lib/cjs/utils/isEndpoint.js.map +1 -0
  14. package/lib/esm/index.js +3 -0
  15. package/lib/esm/index.js.map +1 -1
  16. package/lib/esm/interceptors/PlatformCacheInterceptor.js +19 -13
  17. package/lib/esm/interceptors/PlatformCacheInterceptor.js.map +1 -1
  18. package/lib/esm/services/PlatformCache.js +20 -6
  19. package/lib/esm/services/PlatformCache.js.map +1 -1
  20. package/lib/esm/utils/getInterceptorOptions.js +6 -0
  21. package/lib/esm/utils/getInterceptorOptions.js.map +1 -0
  22. package/lib/esm/utils/getPrefix.js +10 -0
  23. package/lib/esm/utils/getPrefix.js.map +1 -0
  24. package/lib/esm/utils/isEndpoint.js +6 -0
  25. package/lib/esm/utils/isEndpoint.js.map +1 -0
  26. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  27. package/lib/tsconfig.tsbuildinfo +1 -1
  28. package/lib/types/index.d.ts +3 -0
  29. package/lib/types/interceptors/PlatformCacheInterceptor.d.ts +2 -1
  30. package/lib/types/interfaces/PlatformCacheOptions.d.ts +16 -0
  31. package/lib/types/services/PlatformCache.d.ts +9 -2
  32. package/lib/types/utils/getInterceptorOptions.d.ts +3 -0
  33. package/lib/types/utils/getPrefix.d.ts +2 -0
  34. package/lib/types/utils/isEndpoint.d.ts +2 -0
  35. package/package.json +12 -15
@@ -7,3 +7,6 @@ export * from "./interfaces/PlatformCacheOptions";
7
7
  export * from "./interfaces/PlatformCachedObject";
8
8
  export * from "./interfaces/interfaces";
9
9
  export * from "./services/PlatformCache";
10
+ export * from "./utils/getInterceptorOptions";
11
+ export * from "./utils/getPrefix";
12
+ export * from "./utils/isEndpoint";
@@ -18,6 +18,7 @@ export declare class PlatformCacheInterceptor implements InterceptorMethods {
18
18
  cacheResponse(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): Promise<any>;
19
19
  protected getArgs(context: InterceptorContext<unknown, PlatformCacheOptions>): any;
20
20
  protected getOptions(context: InterceptorContext<any, PlatformCacheOptions>): {
21
+ key: string;
21
22
  refreshThreshold: number | undefined;
22
23
  ttl: import("../services/PlatformCache").Ttl | undefined;
23
24
  type: any;
@@ -25,8 +26,8 @@ export declare class PlatformCacheInterceptor implements InterceptorMethods {
25
26
  collectionType: any;
26
27
  keyArgs: string;
27
28
  canCache: ((item: any) => boolean) | undefined;
29
+ $ctx: any;
28
30
  };
29
- protected isEndpoint({ target, propertyKey }: InterceptorContext<any, PlatformCacheOptions>): boolean;
30
31
  protected hasKeyInQueue(key: string): Promise<boolean>;
31
32
  protected addKeyToQueue(key: string): Promise<void>;
32
33
  protected deleteKeyFromQueue(key: string): Promise<void>;
@@ -2,8 +2,24 @@ import { MetadataTypes } from "@tsed/core";
2
2
  import { BaseContext } from "@tsed/di";
3
3
  import type { Ttl } from "../services/PlatformCache";
4
4
  export interface PlatformCacheOptions extends MetadataTypes {
5
+ /**
6
+ * key expiration ttl in seconds.
7
+ */
5
8
  ttl?: Ttl;
9
+ /**
10
+ * By default, the key is generated from the method name and the arguments passed to the method.
11
+ */
12
+ prefix?: string;
13
+ /**
14
+ * Algorithm used to generate the key. By default, the key is generated from the method name and the arguments passed to the method.
15
+ */
6
16
  key?: string | ((args: any[], ctx?: BaseContext) => string);
17
+ /**
18
+ * threshold to refresh the cache.
19
+ */
7
20
  refreshThreshold?: number;
21
+ /**
22
+ * The function determine if the result must be cached or not.
23
+ */
8
24
  canCache?: ((item: any) => boolean) | "no-nullish";
9
25
  }
@@ -1,3 +1,4 @@
1
+ import { Type } from "@tsed/core";
1
2
  import { Configuration, InjectorService } from "@tsed/di";
2
3
  import { JsonDeserializerOptions } from "@tsed/json-mapper";
3
4
  import { Logger } from "@tsed/logger";
@@ -16,6 +17,7 @@ export declare class PlatformCache {
16
17
  protected logger: Logger;
17
18
  get cache(): CacheManager | undefined;
18
19
  $onInit(): Promise<void>;
20
+ getKeysOf(target: Type<any>, propertyKey: string | symbol): Promise<string[]>;
19
21
  disabled(): boolean;
20
22
  defaultKeyResolver(): (args: any[], ctx?: any) => string;
21
23
  defaultTtl(): Ttl;
@@ -31,10 +33,15 @@ export declare class PlatformCache {
31
33
  del(key: string): Promise<void>;
32
34
  reset(): Promise<void>;
33
35
  keys(...args: any[]): Promise<string[]>;
36
+ deleteKeys(patterns: string): Promise<string[]>;
37
+ /**
38
+ * Use micromatch instead native patterns. Use this method if the native store method doesn't support glob patterns
39
+ * @param patterns
40
+ */
34
41
  getMatchingKeys(patterns: string): Promise<string[]>;
35
42
  deleteMatchingKeys(patterns: string): Promise<string[]>;
36
- protected createCacheManager(settings: PlatformCacheSettings): Promise<MultiCache | import("cache-manager").MemoryCache>;
37
- private mapStore;
38
43
  refresh(callback: () => Promise<any> | any): any;
39
44
  isForceRefresh(): boolean;
45
+ protected createCacheManager(settings: PlatformCacheSettings): Promise<MultiCache | import("cache-manager").MemoryCache>;
46
+ private mapStore;
40
47
  }
@@ -0,0 +1,3 @@
1
+ import { Type } from "@tsed/core";
2
+ import { PlatformCacheOptions } from "../interfaces/PlatformCacheOptions";
3
+ export declare function getInterceptorOptions(target: Type<any>, propertyKey: string | symbol): PlatformCacheOptions;
@@ -0,0 +1,2 @@
1
+ import { Type } from "@tsed/core";
2
+ export declare function getPrefix(target: Type<any>, propertyKey: string | symbol): (string | symbol)[];
@@ -0,0 +1,2 @@
1
+ import { Type } from "@tsed/core";
2
+ export declare function isEndpoint(target: Type<any>, propertyKey: string | symbol): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-cache",
3
- "version": "7.35.0-beta.5",
3
+ "version": "7.35.0",
4
4
  "description": "Platform cache module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -27,20 +27,20 @@
27
27
  "tslib": "2.5.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@tsed/core": "7.35.0-beta.5",
31
- "@tsed/di": "7.35.0-beta.5",
32
- "@tsed/eslint": "7.35.0-beta.5",
33
- "@tsed/json-mapper": "7.35.0-beta.5",
34
- "@tsed/schema": "7.35.0-beta.5",
35
- "@tsed/typescript": "7.35.0-beta.5",
30
+ "@tsed/core": "7.35.0",
31
+ "@tsed/di": "7.35.0",
32
+ "@tsed/eslint": "7.35.0",
33
+ "@tsed/json-mapper": "7.35.0",
34
+ "@tsed/schema": "7.35.0",
35
+ "@tsed/typescript": "7.35.0",
36
36
  "@types/micromatch": "^4.0.1",
37
37
  "eslint": "^8.12.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@tsed/core": "^7.35.0-beta.5",
41
- "@tsed/di": "^7.35.0-beta.5",
42
- "@tsed/json-mapper": "^7.35.0-beta.5",
43
- "@tsed/schema": "^7.35.0-beta.5"
40
+ "@tsed/core": "^7.35.0",
41
+ "@tsed/di": "^7.35.0",
42
+ "@tsed/json-mapper": "^7.35.0",
43
+ "@tsed/schema": "^7.35.0"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@tsed/core": {
@@ -62,8 +62,5 @@
62
62
  },
63
63
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-cache",
64
64
  "author": "Romain Lenzotti",
65
- "license": "MIT",
66
- "publishConfig": {
67
- "tag": "beta"
68
- }
65
+ "license": "MIT"
69
66
  }