Caching Function Examples CacheWrapper A non-thread-safe caching decorator package main import ( "fmt" "math/big" "github.com/kashifkhan0771/utils/math" ) // Example function: Compute factorial func factorial(n int) *big.Int { result := big.NewInt(1) for i := 2; i <= n; i++ { result.Mul(result, big.NewInt(int64(i))) } return result } func main() { cachedFactorial := utils.CacheWrapper(factorial) fmt.Println(cachedFactorial(10)) } Output: 3628800 SafeCacheWrapper A thread-safe caching decorator package main import ( "fmt" "math/big" "github.com/kashifkhan0771/utils/math" ) // Example function: Compute factorial func factorial(n int) *big.Int { result := big.NewInt(1) for i := 2; i <= n; i++ { result.Mul(result, big.NewInt(int64(i))) } return result } func main() { cachedFactorial := utils.SafeCacheWrapper(factorial) fmt.Println(cachedFactorial(10)) } Output: 3628800