fastcache has no expiration by design, its benchmark table breaks mid-row, and it still depends on BigCache
Fast thread-safe inmemory cache for big number of entries in Go. Minimizes GC overhead
At a glance
- What is it?
- fastcache is a Go in-memory cache built to hold a very large number of entries without dragging the garbage collector with it, extracted from the VictoriaMetrics monitoring system. It is unusual in what it refuses to do: no expiration, no eviction callbacks, no herd protection. It is also unusual in what it keeps: a 2019 pseudo-version of the library it was designed to beat, and a benchmark excerpt that stops in the middle of a row.
- Who is it for?
- fastcache is the right shape for a workload that holds millions of small, short-lived facts and cares about allocation rate more than about feature coverage, which is precisely the workload a time series database creates. Three things to know before you reach for it.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 153 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- VictoriaMetrics/fastcache2,373 ★ · -1
| Repository | 2026-09-30 | 2026-11-15 |
|---|---|---|
| VictoriaMetrics/fastcache | 2.4k | 2.4k |
-1 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
No expiration, by decision, with the workaround in the FAQ
The limitations section states three constraints and the second one is the important one. Keys and values must be byte slices, so anything else is marshaled first. Entries over 64KB have to go through a separate API, which puts a size cliff exactly at the chunk size. And there is no cache expiration at all: entries are evicted only when the cache overflows its configured maximum size, and if you need a deadline you should store one inside the value. The FAQ then gives the reason, which is a sentence about the parent project: entries inside the monitoring system never expire, so expiration was never needed. And it gives the recipe, which is to marshal a deadline into the value and check it after reading. So the feature is absent by choice and the workaround is documented in the same file.
A thousandfold drop in pointers is the whole argument
The architecture section explains the design in one comparison that carries the argument. The cache is many buckets, each with its own lock, so several processors work on different buckets at once. Each bucket holds a map from key hash to the position of the key and value, plus 64KB byte slices that hold the encoded entries. And each bucket therefore contains only a number of pointers proportional to its chunk count. The worked example: a 64GB cache would hold about a million pointers, where a map with byte slice keys and values of the same size would hold about a billion for short keys and values. That is a thousand times fewer pointers for the collector to trace, and it is why the page is willing to say the whole design exists to avoid collector overhead on large heaps.
The benchmark excerpt stops in the middle of a row
The performance section prints raw benchmark output, which is the right choice and slightly undermines itself here. The command is given with four processors and ten seconds per case:
GOMAXPROCS=4 go test github.com/VictoriaMetrics/fastcache -bench='Set|Get' -benchtime=10sFour complete rows appear, and what the design is for shows up in the allocation column:
BenchmarkBigCacheSet-4 2000 10566656 ns/op 6.20 MB/s 4660369 B/op 6 allocs/op
BenchmarkBigCacheGet-4 2000 6902694 ns/op 9.49 MB/s 684169 B/op 131076 allocs/op
BenchmarkBigCacheSetGet-4 1000 17579118 ns/op 7.46 MB/s 5046744 B/op 131083 allocs/op
BenchmarkCacheSet-4 5000 3808874 ns/op 17.21 MB/s 1142 B/op 2 allocs/opThen the fifth row begins and stops after the first digit of its iteration count. So the fastest reading number the library most wants to show is the one missing, and the comparison the page summarises as faster in all cases rests on a table that ends early. The text below it is where the correction lives, and the correction is about units.
The megabytes per second column is wrong and prose says so
The line under the benchmark block says the throughput column does not mean megabytes per second at all, but millions of operations per second, and that is why the numbers look implausibly large for a cache. So the library publishes machine output it does not control, from a tool whose units are wrong for this use, and corrects it in a sentence of prose rather than in the output. Read through that lens, the table still supports the claim it makes. BigCache writes in 10.5 milliseconds per operation against fastcache's 3.8, a factor of roughly three. More telling is the allocation count on the read path, where BigCache shows 131,076 allocations per operation. That number is the design argument restated as a measurement.
The comparison library is still a direct dependency
The page says the cache uses ideas from BigCache, which is the phrasing of credit rather than reuse. The module file tells a more complicated story: BigCache is a direct requirement, pinned at a pseudo-version dated February 2019, alongside a hash library, a compression library and the system calls package. A cache whose pitch is a minimal surface therefore carries a seven year old pseudo-version of the library it publishes benchmarks against, and the reason is almost certainly the benchmark itself rather than the cache. It is a small thing, and a reader who is only using the cache will not notice it, but it does mean the module graph is not quite the picture the feature list paints. Two test-only dependencies are also present, one of them an assertion library from 2018.
Off-heap means two files and a build decision
The architecture notes say chunks are allocated off the heap if possible, and the claim attached to that is about frequency rather than capacity: the collector reclaims unused memory more often without needing the heap growth setting tuned. Two files at the repository root are the implementation of that sentence, one for the heap allocator and one for the memory-mapped allocator, so the off-heap path is a compile-time choice rather than a runtime one. The remaining root files follow the same shape as the library itself: the cache, an inlined copy of the comparison cache, the file save and load implementation, and three test files for the cache, the comparison cache and the file layer, each with a timing variant. A vendored directory is also committed.
The intended usage is to copy the file and add the feature
The FAQ answers the missing features question with an instruction rather than a roadmap. No thundering herd protection, no callbacks on eviction, and the stated reason is that both would complicate the code and make it faster to read but slower to run. Then the sentence that tells you how the project expects to be used: the source is simple, so just copy it and implement the feature you want on top of it. Combined with the note that the API is designed for zero-allocation mode, this is a library meant to be taken rather than wrapped. The provenance explains the rest: it was extracted from the VictoriaMetrics sources, and every product decision on the page, no expiration, no callbacks, no herd protection, follows from what a monitoring system's query path does not need.
Editorial conclusion
fastcache is the right shape for a workload that holds millions of small, short-lived facts and cares about allocation rate more than about feature coverage, which is precisely the workload a time series database creates. Three things to know before you reach for it. There is no time to live, so if your data has an age you must carry a deadline inside the value and check it after reading, exactly as the project suggests. There is no eviction callback, so nothing gets told when an entry leaves. And there is no herd protection, so a hot key expiring under load will be recomputed by every goroutine at once. None of those are oversights; the project says so plainly and explains that adding them would complicate the code and slow it down. If you need those features, the intended move is to take the source and implement them, and the whole file is small enough to read in one sitting before you decide.
Frequently asked questions
What is VictoriaMetrics fastcache?
A thread-safe in-memory cache for Go designed to hold a very large number of entries without garbage collector overhead, extracted from the VictoriaMetrics monitoring sources. It can be saved to a file and loaded back.
Does fastcache support TTL or expiration?
No. Entries are evicted only when the cache exceeds its maximum size. The project suggests storing a deadline inside the value and checking it after reading, since the parent system never needed expiration.
What are the limitations of fastcache?
Keys and values must be byte slices, so other types must be marshaled before storing, and entries larger than 64KB must be stored through a separate API. There is no expiration.
How does fastcache compare to BigCache?
The page publishes benchmarks against BigCache, the standard Go map and sync.Map, and states that fastcache is faster in all cases. Its writing path allocates 1,142 bytes per operation against BigCache's 4,660,369, and BigCache's reading path shows 131,076 allocations per operation.
How do I add a feature fastcache does not have?
The project's own answer is to copy the source and implement it on top, for example expiration, eviction callbacks or herd protection, because adding those to the library would complicate the code and make it slower.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/victoriametrics-fastcache)Star history chart for your README
[](https://hysenlabs.com/projects/victoriametrics-fastcache)Was this useful?