An Nx remote cache implementation using Redis. This package is inspired by nx-remotecache-redis, so a big thanks 👍👌🎉 to SQLExceptionPhil —many ideas were taken from that project!
This package uses the new OpenAPI specification for custom remote cache implementations and is compatible with Nx version 21. See Self-Host Cache for details.
You can use the cache by installing the npm package in your Nx workspace. It provides the ability to start a local server that interacts with a remote Redis database instance, specified via an environment variable.
npm install nx-redis-cache@latest
You must set the REDIS_URL environment variable to point to a running Redis instance. The example below assumes a local Redis server.
For testing, you can spin up Redis in Docker—see start-local-redis for a one-liner.
env REDIS_URL=redis://localhost:6379 npx nx-redis-cache start --verbose
env NX_SELF_HOSTED_REMOTE_CACHE_SERVER=http://127.0.0.1:3000 npx nx run-many -t=build
npx nx-redis-cache stop
Variable | Description |
---|---|
REDIS_URL |
Redis connection URL (e.g., redis://localhost:6379 ) |
You can use
npx nx-redis-cache cache-stats
to print some stats about the last run of a command. It uses the nx generate run.json file in your local cache directory