Function: Memo()
Less than 1 minute
AspectJS • Docs
Function: Memo()
Memo(...
args
):any
Annotation to declare a method as memoizable.
The @Memo
annotation is used to mark a method as memoizable, meaning its return value will be cached and subsequent calls to the method with the same arguments will return the cached result quickly instead of executing the method again. The memoization occurs when the MemoAspect aspect is enabled.
Parameters
• ...args: [MemoOptions
]
Returns
any
Example
import { Memo } from '@aspectjs/core';
class MyClass {
@Memo()
expensiveCalculation(arg1: string, arg2: number): string {
// Perform expensive calculation
return result;
}
}
Defined in
packages/memo/src/memo.annotation.ts:29