Skip to content
Anders Björklund edited this page Apr 13, 2026 · 56 revisions

Ccache 4.4+ has support for using the Redis protocol to communicate with a server for the purpose of sharing cache results with others. This page contains hints on how to set up such a server for use with ccache.

See the Remote storage backends section in the ccache manual for details on how to configure ccache.

In general, ccache will use the EXISTS and GET commands to read from the cache server. To optionally also update cache entries, ccache will use the SET command, and furthermore, ccache may use the DEL command.

See also HTTP storage.

Redis

Redis CE

Redis is an open source data store server that can be used as an LRU cache for remote ccache storage.

  1. Add something like this to the Redis configuration:

    # Allow up to 2 GB of cache:
    maxmemory 2G
    # Configure LRU (least recently used) eviction:
    maxmemory-policy allkeys-lru
  2. Add remote_storage = redis://YOUR_SERVER to your ccache configuration (or set CCACHE_REMOTE_STORAGE=redis://YOUR_SERVER if you're using environment variables).

NOTE: Since Redis is an in-memory database it may not be a good idea to use a single server for a large caches but instead set up a server cluster. That can be done with the shards attribute described in Remote storage backends.

NOTE: Since Redis is single-threaded, you might need to run more than one instance per server. See for instance 13 Years Later – Does Redis Need a New Architecture? which recommends not having more than 25 GB per Redis process.

TODO: Maybe write some recommendation about persistence?

Options:

  • RDB (Redis Database): The RDB persistence performs point-in-time snapshots of your dataset at specified intervals.

  • AOF (Append Only File): The AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset.

  • None (No Persistence): The database is kept in-memory only, and deleted when the server is restarted for any reason.

  • NDS (Naive Disk Store): The NDS persistence is implemented by persisting every change to a key to an on-disk database, through a periodic "flush" of all keys that have changed (controlled by the same logic as RDB dumps).

Note:

The NDS is based on a patched version of Redis. There are also other alternative Redis-compatible disk-based databases.

Valkey

Valkey is a fork from the open source Redis project right before the transition to their new source available licenses.

Note:

Redis version 7 initially used a BSD license. Redis version 8 changed licenses again (see blog), from SSPL to AGPLv3.

Redis Enterprise

Commercial Redis (not Open Source) had something called "Redis on Flash".

The feature is now called "Redis Flex", and changed from RocksDB to Speedb.

References:

Redis with NDS

See REDIS-NDS and LMDB (liblmdb).

Updated version REDIS-NDS (2.6->7.0)

References:

Alternative servers

Most alternative servers use LevelDB or RocksDB for the disk storage. Some also offer memory-mapped databases.

Kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.

  1. Docker
docker run -d -p 6666:6666 apache/kvrocks --bind 0.0.0.0
redis-cli -p 6666

See https://kvrocks.apache.org/docs/getting-started

Redka

Redka is Redis re-implemented with SQL, either SQLite (in-memory or disk-based) or PostgreSQL. It is not as fast, but simple to maintain.

  1. In-memory
docker run --rm -p 6379:6379 nalgeon/redka
  1. Disk-based
docker run -d -p 7379:6379 -v /data nalgeon/redka redka.db
redis-cli -p 7379

See https://github.com/nalgeon/redka/blob/main/docs/usage-standalone.md

SableDB

SableDB is a key-value NoSQL database that utilizes RocksDB as its storage engine and is compatible with the Valkey protocol.

KeyDB

KeyDB is a fork of Redis from 2021, with a focus on multithreading, memory efficiency, and high throughput.

KeyDB FLASH (currently a Beta feature) is built on RocksDB and is persistent to the storage medium (normally SSD).

Aerospike

Aerospike is an open source database that can be used for remote ccache storage, both memory and disk based.

One can use the Redis backend with the "skyhook" proxy, or a custom ccache Aerospike backend using libaerospike.

Tendis

Tendis is a high-performance distributed storage system which is fully compatible with the Redis protocol.

High Availability

High availability and cross-datacenter replication:

Redis Cluster

TODO: https://redis.io/docs/latest/operate/oss_and_stack/management/scaling/

Redis Sentinel

TODO: https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/

DynomiteDB

TODO: https://github.com/Netflix/dynomite

Proxy

Twemproxy

As an alternative to ccache's own client-side partitioning support via the shards attribute, you can use proxy-assisted partitioning with a local proxy like twemproxy (nutcracker). Configuration looks something like this:

pool:
  listen: 127.0.0.1:6379
  preconnect: true
  redis: true
  servers:
    - 1.2.3.4:6379:3 server1
    - 5.6.7.8:6379:4 server2

With this nutcracker.yml, connections to localhost (127.0.0.1) will be forwarded to server1 (1.2.3.4) and server2 (5.6.7.8). The weights (3 and 4 in the example) can be either 1 for all servers (even distribution) or the allocated memory for each in case of different sizes.

Redis Cluster Proxy

Redis Cluster is a deployment topology that needs client support. It has both master nodes and replica nodes in the cluster, always communicating with each other.

This client support is not available in ccache directly. However, you can use redis-cluster-proxy to communicate with such a cluster. It will handle the connection to the cluster and provides a regular address such as 127.0.0.1:7777.

Example:

redis-cluster-proxy --bind 127.0.0.1 --port 7777 127.0.0.1:7000

Clone this wiki locally