Release Notes
New Features
-
MemoizeCtx Functions: Introduced a new set of
MemoizeCtx
functions to support memoization of functions that accept acontext.Context
parameter. These functions allow for efficient caching and retrieval of results based on input parameters and context, improving performance for expensive or frequently called functions.MemoizeCtx
: Memoizes a function with context and no parameters.MemoizeCtx1
: Memoizes a function with context and 1 parameter.- ... until
MemoizeCtx7
Enhancements
- Hide entries attr of the cache class.
- Concurrency Support: The
MemoizeCtx
functions are designed to be thread-safe and concurrent-safe, ensuring reliable performance in multi-threaded environments.
Examples
Basic Memoization with Context
computeCtxFn := func(ctx context.Context) int {
// Expensive computation
return 42
}
memoizedCtxFn := MemoizeCtx(computeCtxFn, 10*time.Second)
result := memoizedCtxFn(context.Background())
Memoization with Context and Parameters
computeCtxFn := func(ctx context.Context, a int) int {
// Expensive computation
return a * 2
}
memoizedCtxFn := MemoizeCtx1(computeCtxFn, 10*time.Second)
result := memoizedCtxFn(context.Background(), 5)
Bug Fixes
- N/A
Known Issues
- N/A
Documentation
- Updated the
README.md
to include usage examples and descriptions for the newMemoizeCtx
functions.