Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

otter

> 数据库
Open source

A high performance caching library for Go

2.7K stars0 likes1 views
WebsiteGitHub

About

A high performance caching library for Go

In-memory caching library

Otter is designed to provide an excellent developer experience while maintaining high performance. It aims to address the shortcomings of its predecessors and incorporates design principles from high-performance libraries in other languages (such as Caffeine).

Contents

  • Features
  • Usage
    • Requirements
    • Installation
    • Examples
  • Performance
    • Throughput
    • Hit ratio
    • Memory consumption
  • Projects using Otter
  • Related works
  • Contribute
  • License

✨ Features

Performance-wise, Otter provides:

  • High hit rates across all workload types via adaptive W-TinyLFU
  • Excellent throughput under high contention on most workload types
  • Among the lowest memory overheads across all cache capacities
  • Automatic data structures configuration based on contention/parallelism and workload patterns

Otter also provides a highly configurable caching API, enabling any combination of these optional features:

  • Size-based eviction when a maximum is exceeded
  • Time-based expiration of entries, measured since last access or last write
  • Automatic loading of entries into the cache
  • Asynchronously refresh when the first stale request for an entry occurs
  • Writes propagated to an external resource
  • Accumulation of cache access statistics
  • Saving cache to a file and loading cache from a file

Usage

For more details, see our user's guide and browse the API docs for the latest release.

Requirements

Otter requires Go version 1.24 or above.

️ Installation

With v1

bash
go get -u github.com/maypok86/otter

With v2

bash
go get -u github.com/maypok86/otter/v2

See the release notes for details of the changes.

Note that otter only supports the two most recent minor versions of Go.

Otter follows semantic versioning for the documented public API on stable releases. v2 is the latest stable major version.

✏️ Examples

Otter uses a plain Options struct for cache configuration. Check out otter.Options for more details.

Note that all features are optional. You can create a cache that acts as a simple hash table wrapper, with near-zero memory overhead for unused features — thanks to node code generation.

API Usage Example

…

You can find more usage examples here.

Performance

The benchmark code can be found here.

Throughput

Throughput benchmarks are a Go port of the caffeine benchmarks. This microbenchmark compares the throughput of caches on a zipf distribution, which allows to show various inefficient places in implementations.

You can find results here.

Hit ratio

The hit ratio simulator tests caches on various traces:

  1. Synthetic (Zipf distribution)
  2. Traditional (widely known and used in various projects and papers)

You can find results here.

Memory consumption

This benchmark quantifies the additional memory consumption across varying cache capacities.

You can find results here.

️ Projects using Otter

Below is a list of known projects that use Otter:

  • Grafana: The open and composable observability and data visualization platform.
  • Centrifugo: Scalable real-time messaging server in a language-agnostic way.
  • FrankenPHP: The modern PHP app server.
  • Unkey: Open source API management platform.
  • Nuclei: A fast, open-source, and highly customizable vulnerability scanner.
  • git-pages: Scalable static page server for Git forges (like GitHub Pages or Netlify).

Related works

Otter is based on the following papers:

  • BP-Wrapper: A Framework Making Any Replacement Algorithms (Almost) Lock Contention Free
  • TinyLFU: A Highly Efficient Cache Admission Policy
  • Adaptive Software Cache Management
  • Denial of Service via Algorithmic Complexity Attack
  • Hashed and Hierarchical Timing Wheels
  • A large scale analysis of hundreds of in-memory cache clusters at Twitter

Contribute

Contributions are welcome as always, before submitting a new PR please make sure to open a new issue so community members can discuss it. For more information please see contribution guidelines.

Additionally, you might find existing open issues which can help with improvements.

This project follows a standard code of conduct so that you can understand what actions will and will not be tolerated.

License

This project is Apache 2.0 licensed, as found in the LICENSE.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gocachegoperformancew-tinylfu

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库