Skip to content

About

Ccache Redis storage helper

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

ccache-storage-redis

A ccache remote storage helper for Redis.

Overview

This is a storage helper for ccache that enables caching compilation results on Redis servers. It implements the ccache remote storage helper protocol.

Features

  • Supports the Redis protocol over unencrypted or TLS/SSL network connections, as well as over unencrypted over local Unix domain socket connections
  • Cross-platform: Linux, macOS, Windows
  • Optional debug logging

Installation

The helper should be installed in a location where ccache searches for helper programs. Install it as:

  • ccache-storage-redis for unencrypted Redis
  • ccache-storage-rediss for Redis TLS/SSL
  • ccache-storage-redis+unix for Redis on local Unix domain socket

URL formats

  • Unencrypted: redis://[[USERNAME:]PASSWORD@]HOST[:PORT][/DBNUMBER]
  • TLS/SSL-encrypted: rediss://[[USERNAME:]PASSWORD@]HOST[:PORT][/DBNUMBER]
  • Unix domain socket: redis+unix:SOCKET_PATH[?db=DBNUMBER] or redis+unix://[[USERNAME:]PASSWORD@localhost]SOCKET_PATH[?db=DBNUMBER]

Using a prebuilt binary

Grab a prebuilt binary from Releases and place it in a suitable directory as described above.

Building from source

# Clone the repository:
git clone https://github.com/ccache/ccache-storage-redis
cd ccache-storage-redis

# On Windows:
go mod download
go build -ldflags="-s -w" -trimpath -o ccache-storage-redis.exe .

# On Linux/macOS and similar:
make

# Install ccache-storage-redis plus ccache-storage-rediss and
# ccache-storage-redis+unix symlinks in /usr/local/bin:
make install

# Install ccache-storage-redis  plus ccache-storage-rediss and
# ccache-storage-redis+unix symlinks in /example/dir:
make install INSTALL_DIR=/example/dir

Configuration

The helper is configured via ccache's remote_storage configuration. The binary is automatically invoked by ccache when needed.

For example:

# Set the CCACHE_REMOTE_STORAGE environment variable:
export CCACHE_REMOTE_STORAGE="redis://cache.example.com"

# Or set remote_storage in ccache's configuration file:
ccache -o remote_storage="redis://cache.example.com"

See also the Redis storage wiki page for tips on how to set up a storage server.

Example ccache configuration:

remote_storage = redis://cache.example.com

Or as an environment variable:

export CCACHE_REMOTE_STORAGE="redis://cache.example.com"

Configuration attributes

The helper supports the following custom attributes:

  • @connection-pool-size: Maximum number of connections. Defaults to go-redis's default.

Optional debug logging

You can set the CRSH_LOGFILE environment variable to enable debug logging to a file:

export CRSH_LOGFILE=/path/to/debug.log

Note: The helper process is spawned by ccache, so the environment variable must be set before ccache is invoked.

Warning: The debug log is not redacted and may contain secrets such as credentials. Only enable it for troubleshooting and protect or delete the log file afterwards.

Contributing

Contributions are welcome! Please submit pull requests or open issues on GitHub.

Running tests

Run go test ./... or make test to run the full test suite. Install redis-server or valkey-server in PATH, or set REDIS_SERVER to the server executable. Tests start and stop their own servers using Unix sockets with persistence disabled. Tests that require a server are skipped on Windows.

Use go test -short ./... to skip tests that require a server.

About

Ccache Redis storage helper

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages