@aomex/cache
Advanced tools
Comparing version 3.10.0 to 3.11.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.11.0](https://github.com/aomex/aomex/compare/v3.10.0...v3.11.0) (2024-11-07) | ||
### Features | ||
* **cache:** 支持自动生成key ([5316cc4](https://github.com/aomex/aomex/commit/5316cc4a514e89307c302dac4689b81cf8b1fa71)) | ||
# [3.10.0](https://github.com/aomex/aomex/compare/v3.9.0...v3.10.0) (2024-11-02) | ||
@@ -8,0 +19,0 @@ |
@@ -126,4 +126,4 @@ declare abstract class CacheAdapter { | ||
decorate<T extends Caching.Types | null, P extends (...args: any[]) => Promise<T>, Q extends NonNullable<T>>(opts: { | ||
key: string | ((...args: Parameters<P>) => string); | ||
duration?: number; | ||
key?: string | ((...args: Parameters<P>) => string); | ||
duration: number; | ||
/** | ||
@@ -133,3 +133,3 @@ * 当数据源返回null或者undefined时,则返回默认值 | ||
defaultValue?: Q; | ||
}): (originalMethod: P, _context: ClassMethodDecoratorContext) => (this: object, ...args: Parameters<P>) => Promise<any>; | ||
}): (originalMethod: P, context: ClassMethodDecoratorContext) => (this: object, ...args: Parameters<P>) => Promise<any>; | ||
protected encodeValue(value: Caching.Types): string; | ||
@@ -136,0 +136,0 @@ protected decodeValue(value: string | null, defaultValue?: Caching.Types): any; |
@@ -151,5 +151,5 @@ // src/cache-adapter.ts | ||
const { key: getKey, duration, defaultValue = null } = opts; | ||
return (originalMethod, _context) => { | ||
return (originalMethod, context) => { | ||
return async function(...args) { | ||
const key = typeof getKey === "string" ? getKey : getKey.apply(this, args); | ||
const key = getKey === void 0 ? `${"displayName" in this && typeof this.displayName === "string" ? this.displayName : this.constructor.name}-${String(context.name)}-${JSON.stringify(args)}` : typeof getKey === "string" ? getKey : getKey.apply(this, args); | ||
let value = await instance.get(key); | ||
@@ -156,0 +156,0 @@ if (value === null) { |
{ | ||
"name": "@aomex/cache", | ||
"version": "3.10.0", | ||
"version": "3.11.0", | ||
"description": "缓存基础类", | ||
@@ -34,5 +34,5 @@ "type": "module", | ||
"devDependencies": { | ||
"@aomex/common": "^3.10.0" | ||
"@aomex/common": "^3.11.0" | ||
}, | ||
"scripts": {} | ||
} |
Sorry, the diff of this file is not supported yet
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
45932