@tsed/platform-cache 8.19.4 → 8.20.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.
- package/lib/esm/extends/cache.js +6 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/extends/cache.d.ts +32 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProviderBuilder } from "@tsed/di";
|
|
2
|
+
import { PlatformCacheInterceptor } from "../interceptors/PlatformCacheInterceptor.js";
|
|
3
|
+
ProviderBuilder.add("cache", function cache(propertyKey, options = {}) {
|
|
4
|
+
this.intercept(propertyKey, PlatformCacheInterceptor, options);
|
|
5
|
+
return this;
|
|
6
|
+
});
|
package/lib/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./decorators/useCache.js";
|
|
5
|
+
export * from "./extends/cache.js";
|
|
5
6
|
export * from "./interceptors/PlatformCacheInterceptor.js";
|
|
6
7
|
export * from "./interfaces/interfaces.js";
|
|
7
8
|
export * from "./interfaces/PlatformCachedObject.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Type } from "@tsed/core";
|
|
2
|
+
import type { PlatformCacheOptions } from "../interfaces/PlatformCacheOptions.js";
|
|
3
|
+
declare global {
|
|
4
|
+
namespace TsED {
|
|
5
|
+
interface ClassProviderBuilder<Token extends Type> {
|
|
6
|
+
/**
|
|
7
|
+
* Configures caching for a class method by applying the PlatformCacheInterceptor.
|
|
8
|
+
* The interceptor will cache the method's return value and serve it from cache on subsequent calls.
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import {injectable} from "@tsed/di";
|
|
12
|
+
* import "@tsed/platform-cache";
|
|
13
|
+
*
|
|
14
|
+
* class UserService {
|
|
15
|
+
* async getUsers(): Promise<User[]> {
|
|
16
|
+
* return this.userRepository.find();
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* injectable(UserService)
|
|
21
|
+
* .cache("getUsers")
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param propertyKey - The name of the method to be cached
|
|
25
|
+
* @param options - Optional cache settings (TTL, cache key, etc.)
|
|
26
|
+
* @returns The provider builder instance for method chaining
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
cache(propertyKey: keyof InstanceType<Token>, options?: PlatformCacheOptions): this;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./decorators/useCache.js";
|
|
5
|
+
export * from "./extends/cache.js";
|
|
5
6
|
export * from "./interceptors/PlatformCacheInterceptor.js";
|
|
6
7
|
export * from "./interfaces/interfaces.js";
|
|
7
8
|
export * from "./interfaces/PlatformCachedObject.js";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/platform-cache",
|
|
3
3
|
"description": "Platform cache module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.
|
|
5
|
+
"version": "8.20.0",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"tslib": "2.7.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tsed/barrels": "8.
|
|
32
|
-
"@tsed/core": "8.
|
|
33
|
-
"@tsed/di": "8.
|
|
34
|
-
"@tsed/json-mapper": "8.
|
|
35
|
-
"@tsed/schema": "8.
|
|
36
|
-
"@tsed/typescript": "8.
|
|
31
|
+
"@tsed/barrels": "8.20.0",
|
|
32
|
+
"@tsed/core": "8.20.0",
|
|
33
|
+
"@tsed/di": "8.20.0",
|
|
34
|
+
"@tsed/json-mapper": "8.20.0",
|
|
35
|
+
"@tsed/schema": "8.20.0",
|
|
36
|
+
"@tsed/typescript": "8.20.0",
|
|
37
37
|
"@types/micromatch": "^4.0.9",
|
|
38
38
|
"eslint": "9.12.0",
|
|
39
39
|
"typescript": "5.9.3",
|