docs/en/reference/redis-csc.md
Starting with version 6.0, Redis provides Client-Side Caching which allows clients to maintain local caches of data in a faster and more efficient way. JuiceFS includes full support for this feature, offering significant performance improvements for metadata operations.
Redis Client-Side Caching (CSC) works by:
CLIENT TRACKING ON BCASTThis results in reduced network traffic, lower latency, and higher throughput.
JuiceFS supports Redis CSC through the following options in the metadata URL:
--meta-url="redis://localhost/1?client-cache=true" # Enable client-side caching (always BCAST mode)
--meta-url="redis://localhost/1?client-cache=true&client-cache-size=500" # Set cache size (default 12800)
--meta-url="redis://localhost/1?client-cache=true&client-cache-expire=60s" # Set cache expiration (default: 60s)
client-cache: Enables client-side caching in BCAST mode (set to any value except "false")client-cache-size: Maximum cache size (default: 12800)client-cache-expire: Cache expiration time (default: 60s)client-cache-preload: Number of file objects under the root directory preloaded after mounting. (default: 0)When client-side caching is enabled, JuiceFS caches:
Note: Redis Client Side Cache requires Redis server version 6.0 or higher. Using this feature with older Redis versions will result in errors.
When client-side caching is enabled and client-cache-preload is set, JuiceFS will preload the file-object attributes and entries under the root directory after mounting. This lazy preloading happens in the background and helps to:
The preloading process intelligently prioritizes the most important inodes by:
The preloading process runs in a background goroutine with fail-safe mechanisms and won't block or affect normal file system operations.
JuiceFS uses BCAST mode for simplicity and reliability:
BCAST mode provides the simplest implementation while ensuring cache coherence across all clients.
If you experience crashes or instability with CSC enabled:
client-cache-sizeclient-cache parameterJuiceFS includes robust error handling for various Redis CSC-specific responses to ensure stable operation even when Redis sends unexpected response formats due to client tracking.