caching

package
v1.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 1 Imported by: 0

README

Caching

The caching package provides utilities for creating caching decorators to enhance the performance of functions by storing computed results. It includes both thread-safe and non-thread-safe implementations.

  • SafeCacheWrapper: A thread-safe caching decorator that safely memoizes function results in concurrent environments.

    • Uses sync.Map to ensure thread-safety
    • Caches all results indefinitely (no eviction)
    • Best suited for pure functions with limited input domains
    • Safe for concurrent access but may impact performance under high contention
  • CacheWrapper: A non-thread-safe caching decorator that memoizes function results.

    • Caches all results indefinitely (no eviction)
    • Best suited for pure functions with limited input domains
    • Not safe for concurrent access
    • Use SafeCacheWrapper for concurrent scenarios

Examples:

For examples of each function, please checkout EXAMPLES.md


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheWrapper

func CacheWrapper[T comparable, R any](fn func(T) R) func(T) R

CacheWrapper is a non-thread-safe caching decorator.

func SafeCacheWrapper

func SafeCacheWrapper[T comparable, R any](fn func(T) R) func(T) R

SafeCacheWrapper is a thread-safe caching decorator.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL