A Go library for creating a distributed in-memory cache with eventual consistency and cache stampede prevention.
bcache is a Go library for creating a distributed in-memory cache that runs inside your application. It provides eventual consistency across nodes and prevents cache stampede by coordinating cache fills, making it ideal for low-latency caching needs without relying on external cache services.
Go developers building distributed applications that require fast, in-memory caching with synchronization across multiple instances, especially those who want to avoid the network overhead of external caches like Redis.
Developers choose bcache for its simplicity, performance, and ability to eliminate extra network hops by embedding caching directly in the application, while providing robust features like cache stampede prevention and automatic node discovery.
Eventually consistent distributed in-memory cache Go library
By embedding the cache in the application, bcache eliminates the network latency associated with external caches like Redis, as highlighted in the 'Why using it' section for low-latency needs.
The GetWithFiller function ensures only one goroutine populates a missing key, preventing cache stampede, which is explicitly detailed in the 'Cache filling' section of the README.
Nodes automatically discover each other via gossip protocol with minimal configuration of bootstrap nodes, making deployment easy, as explained in the 'How it Works' part.
As an in-memory library, it reduces the need for managing separate cache servers, aligning with its lightweight philosophy mentioned in the README's introduction.
Synchronization via gossip protocol means data replication is not immediate, leading to potential stale reads, which might not suit applications needing strong consistency.
Only supports LRU eviction and basic Set, Get, Delete operations; it lacks features like TTL per key with flexible policies or built-in persistence, as admitted in the README's focus on simplicity.
Cache size is limited by each node's RAM, as cautioned in the 'Why using it' section, which can restrict use with large datasets or in memory-constrained environments.
bcache is an open-source alternative to the following products:
An open-source, in-memory data structure store used as a database, cache, and message broker. It supports various data structures such as strings, hashes, lists, sets, and more.
Memcached is a high-performance, distributed memory object caching system that speeds up dynamic web applications by reducing database load through caching data in RAM.
groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
Efficient cache for gigabytes of data written in Go.
A high performance memory-bound Go cache
☔️ A complete Go cache library that brings you multiple ways of managing your caches
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.