A concurrency-safe Go caching library with expiration capabilities and access counters.
cache2go is a concurrency-safe in-memory caching library for Go, designed to store arbitrary data types with configurable expiration times. It solves the problem of efficiently caching frequently accessed data in multi-goroutine environments, reducing latency and backend load.
Go developers building applications that require fast, thread-safe caching, such as web servers, APIs, or data processing pipelines.
Developers choose cache2go for its simplicity, built-in concurrency safety, and flexible expiration features without external dependencies, making it a lightweight alternative to more complex caching solutions.
Concurrency-safe Go caching library with expiration capabilities and access counters
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses synchronization to ensure safe access from multiple goroutines without data races, as explicitly stated in the README's key features, making it reliable for concurrent Go applications.
Supports item expiration after a fixed duration or never, with automatic cleanup, reducing manual management overhead and highlighted in the example code for easy implementation.
Allows storing any Go data type, including structs and slices, as keys and values, enhancing versatility for diverse caching needs, as demonstrated in the provided example with a custom struct.
Offers hooks like AboutToDeleteItem for executing custom logic before item removal, enabling advanced use cases such as logging or cleanup, as shown in the README example.
As an in-memory cache, all data is lost on application restart, which the README does not address, limiting its use for scenarios requiring durable cache storage.
Relies solely on expiration for cleanup; while it tracks access counts, it lacks built-in policies like LRU or LFU, which might necessitate custom implementations for optimal cache management.
Designed for use within a single Go process, making it unsuitable for distributed systems or clustered environments where shared cache access is needed, as noted in its minimal architecture.