coocood/freecache

A cache library for Go with zero GC overhead.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 21 minutes ago
Added to GitGenius on September 12th, 2026
Created on April 29th, 2015
Open Issues & Pull Requests: 41 (+0)
GitHub issues: Enabled
Number of forks: 411
Total Stargazers: 5,408 (+0)
Total Subscribers: 108 (+0)

Repository Insights (GitGenius)

Most active contributors

Sign in to see contributor activity.

Related repositories by overlapping contributors

No overlapping-contributor repos identified yet.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 4
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,270 days
Stale 30+ days: 4
Stale 90+ days: 4

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

FreeCache is a cache library for Go that eliminates garbage collection overhead while maintaining high concurrent performance.

The problem FreeCache solves is the expensive GC latency introduced by long-lived objects in memory. Traditional in-memory caches force developers to choose between storing many objects and accepting GC pauses, or limiting cache size to keep GC manageable. FreeCache achieves zero GC overhead by drastically reducing the number of pointers in the system. Rather than creating individual pointer allocations for each cached entry, the library uses a fixed architecture: the entire dataset is sharded into 256 segments by key hash, with each segment containing only two pointers—one for a ring buffer storing keys and values, and one for an index slice used for lookups. This design allows the cache to store hundreds of millions of entries without triggering additional garbage collection, regardless of cache size.

FreeCache suits applications that need to cache large numbers of objects in memory while maintaining predictable latency. It works well for systems where GC pauses are unacceptable, such as low-latency services or high-throughput data processing. The library includes expiration support with nearly-LRU eviction semantics, strictly enforces memory limits through preallocation, and provides thread-safe concurrent access through per-segment locking. It comes with a toy Redis-compatible server supporting basic commands with pipelining, and offers iterator support for scanning cached entries. Benchmark results show Set operations are roughly twice as fast as Go's built-in map, though Get operations are somewhat slower in single-threaded scenarios; however, the library is designed to outperform a single-lock-protected map significantly in multi-threaded environments.

Development activity shows consistent maintenance with attention to practical deployment concerns. The project documents important operational details including memory preallocation requirements and the interaction between GC tuning and cache sizing. The expiration semantics are precisely specified, noting that effective cache duration falls within a one-second window due to sub-second time truncation during expiration calculation. The roadmap indicates planned features for persistence and runtime resizing, suggesting ongoing evolution to meet user needs.