Class: MemoAspect
Less than 1 minute
AspectJS • Docs
Class: MemoAspect
Aspect that enables memoization of method results.
The MemoAspect is an aspect that can be applied using the @Memo
annotation to enable memoization of method results. When a method is marked with @Memo
, the aspect will cache the returned value of the method based on the method arguments. Subsequent calls to the method with the same arguments will return the cached result quickly instead of executing the method again.
Remarks
This aspect requires the use of the @aspectjs/core
package.
Example
import { Memo } from '@aspectjs/core';
class MyClass {
@Memo()
expensiveCalculation(arg1: string, arg2: number): string {
// Perform expensive calculation
return result;
}
}
Methods
clear()
clear():
void
Clears the memoization cache. This method resets the unique identifier used for memoization, causing subsequent method calls to be treated as new calls and re-executed.
Returns
void
Defined in
packages/memo/src/memo.aspect.ts:74