### Compile and Install ccache from Source Source: https://github.com/ahufan/xcache/blob/master/client/doc/INSTALL.md Commands to compile and install ccache from the source repository. This process involves running autogen.sh, configuring the build, compiling the source code, and finally installing the compiled binaries. The `./configure` command accepts options to customize the installation directory and other parameters; run `./configure --help` for a full list. ```bash ./autogen.sh ./configure make make install ``` -------------------------------- ### Compile and Install ccache Source: https://github.com/ahufan/xcache/blob/master/client/doc/INSTALL-from-release-archive.md Standard commands to compile and install ccache from a release archive. The `./configure` command can accept options to customize the installation directory and other parameters, accessible via `./configure --help`. ```bash ./configure make make install ``` -------------------------------- ### Starting the XCACHE Server Source: https://context7.com/ahufan/xcache/llms.txt Commands to start an xcache server instance with various configuration options, including port, memory limit, daemon mode, LRU settings, and proxy mode. ```APIDOC ## Starting the XCACHE Server Start an xcache server instance with specified port, memory limit, and daemon mode. ### Example 1: Basic server start ```bash xcache -d -c -p 20190 -m 1 ``` ### Example 2: Custom LRU settings ```bash xcache -d -c -p 20190 -m 2 -l 50-100-2000-100-2 ``` ### Example 3: Start as proxy server ```bash xcache -d -c -p 6666 -P ``` ### Example 4: Max memory limit ```bash xcache -d -c -p 20190 -m 5 -M 10 ``` ### Parameters - `-d`: Run as daemon - `-c`: Enable core dumps - `-p `: Specify server port - `-m `: Set initial memory limit in GB - `-M `: Set maximum memory limit in GB (for auto-expansion) - `-P`: Start as a proxy server (no storage) - `-l `: Configure LRU settings (min-max-count-interval-switcher) - `min`: Hot item threshold (seconds) - `max`: Warm item threshold (seconds) - `count`: Number of items to recycle - `interval`: Recycle interval (seconds) - `switcher`: LRU eviction mode (0=off, 1=update only, 2=update+recycle) ``` -------------------------------- ### Verify XCache Installation and Help Source: https://context7.com/ahufan/xcache/llms.txt These commands verify that the XCache executables (xcache, xcache_monitor, xcache_client) are installed and accessible in the system's PATH. Running them with the -h flag displays their respective help messages, confirming proper installation and providing information on their usage. ```bash xcache -h xcache_monitor -h xcache_client --version ``` -------------------------------- ### Compile Xcache from Source Source: https://context7.com/ahufan/xcache/llms.txt Instructions for building the xcache server, client tools, and monitor from source code. Includes steps for compiling the server and client components and installing the binaries. ```bash # Build xcache server and monitor cd server make -j $(nproc) # Produces: xcache (server), xcache_monitor (admin tool) # Build xcache_client (ccache with remote storage) cd client ./autogen.sh ./configure make -j $(nproc) # Produces: xcache_client (in src/ directory) # Install binaries sudo cp server/xcache /usr/local/bin/ sudo cp server/xcache_monitor /usr/local/bin/ sudo cp client/src/xcache_client /usr/local/bin/ ``` -------------------------------- ### Start XCACHE Server Instance Source: https://context7.com/ahufan/xcache/llms.txt Starts an xcache server instance with specified port, memory limit, and daemon mode. Supports custom LRU settings, proxy mode, and automatic memory expansion up to a maximum limit. ```bash # Start xcache server on port 20190 with 1GB memory as daemon with core dumps enabled xcache -d -c -p 20190 -m 1 # Start xcache server with custom LRU settings (min-max-count-interval-switcher) # Hot items: <= 50 seconds, Warm: 50-100 seconds, Cold: >= 100 seconds # Recycle 2000 items every 100 seconds with update+recycle enabled xcache -d -c -p 20190 -m 2 -l 50-100-2000-100-2 # Start xcache as proxy server (no storage, just routing) xcache -d -c -p 6666 -P # Start with max memory limit (auto-expand up to 10GB from initial 5GB) xcache -d -c -p 20190 -m 5 -M 10 ``` -------------------------------- ### Starting Moxi Proxy for Memcached Sharing Source: https://github.com/ahufan/xcache/blob/master/client/doc/MANUAL.adoc This command starts the moxi proxy, which facilitates sharing memcached connections among multiple ccache instances. It can improve performance by reducing network overhead and allows for fine-tuning of connection settings. The example shows connecting to two memcached servers. ```bash moxi -z 11211=mc_server1:11211,mc_server2:11211 ``` -------------------------------- ### Install ccache for Symbolic Link Usage Source: https://github.com/ahufan/xcache/blob/master/client/doc/INSTALL-from-release-archive.md Commands to install ccache for system-wide usage by creating symbolic links. This method ensures ccache is used for all compilations by making it appear as the actual compiler. Ensure the symbolic link path precedes the original compiler path. ```bash cp ccache /usr/local/bin/ ln -s ccache /usr/local/bin/gcc ln -s ccache /usr/local/bin/g++ ln -s ccache /usr/local/bin/cc ln -s ccache /usr/local/bin/c++ ``` -------------------------------- ### Manage Xcache Key-Value Pairs via Monitor Source: https://context7.com/ahufan/xcache/llms.txt Provides command-line interface for direct key-value operations on xcache servers. Supports setting, getting, deleting keys, and configuring proxy settings. Useful for testing and administration. ```bash # Set a key-value pair xcache_monitor -s 127.0.0.1:20190[mykey,myvalue] # Get a value by key xcache_monitor -g 127.0.0.1:20190[mykey] # Output: len = 7 # myvalue # Delete a key xcache_monitor -d 127.0.0.1:20190[mykey] # Set proxy configuration (internal key) xcache_monitor -S 127.0.0.1:6666["--SERVER=127.0.0.1:20190 10"] # Get proxy configuration (internal key) xcache_monitor -G 127.0.0.1:6666 ``` -------------------------------- ### Integrate Xcache with C/C++ Applications using C API Source: https://context7.com/ahufan/xcache/llms.txt Enables embedding xcache functionality directly into C/C++ applications. Provides functions for initialization, setting, getting, and deleting key-value pairs. Requires including the 'xcache.h' header. ```c #include "xcache.h" #include #include int main() { // Initialize connection to xcache servers // conf format: "--SERVER=127.0.0.1:20190 10" or "--PROXY=127.0.0.1:6666" char* conf = "--SERVER=127.0.0.1:20190 10"; if (x_init(conf) != 0) { fprintf(stderr, "Failed to initialize xcache\n"); return 1; } // Set a key-value pair const char* key = "compile_hash_abc123"; const char* value = "binary_output_data_here"; uint32_t nkey = strlen(key); uint32_t nvalue = strlen(value); if (x_set(nkey, key, nvalue, value) != 0) { fprintf(stderr, "Failed to set key\n"); return 1; } // Retrieve value by key int retrieved_len = 0; char* retrieved_value = x_get(nkey, key, &retrieved_len); if (retrieved_value != NULL) { printf("Retrieved value (len=%d): %.*s\n", retrieved_len, retrieved_len, retrieved_value); free(retrieved_value); } else { printf("Key not found\n"); } // Delete a key if (x_del(nkey, key) == 0) { printf("Key deleted successfully\n"); } return 0; } ``` -------------------------------- ### Monitor XCACHE Server Statistics Source: https://context7.com/ahufan/xcache/llms.txt Queries server statistics and health status for monitoring and diagnostics. Includes commands to check if servers are alive, get detailed statistics, and verify connectivity by touching servers. ```bash # Check if servers are alive (basic info) xcache_monitor -i 127.0.0.1:20190,127.0.0.1:20191 # Output: host: 127.0.0.1:20190 is alive # host: 127.0.0.1:20191 is alive # Get detailed statistics (memory usage, hit rates, item counts) xcache_monitor -I 127.0.0.1:20190,127.0.0.1:20191 # Touch servers to verify connectivity xcache_monitor -t 127.0.0.1:20190,127.0.0.1:20191 ``` -------------------------------- ### Configure Proxy Cluster for Load Balancing Source: https://context7.com/ahufan/xcache/llms.txt Sets up a proxy server to manage a cluster of xcache servers with load balancing. Uses xcache_monitor to configure the proxy with backend servers and demonstrates how clients retrieve configurations from the proxy. ```bash # Start proxy server xcache -d -c -p 6666 -P # Configure proxy with backend servers using xcache_monitor # Format: xcache_monitor -S proxy_ip:proxy_port"--SERVER=xcache_ip:xcache_port xcache_core" xcache_monitor -S 127.0.0.1:6666["--SERVER=127.0.0.1:20190 10 --SERVER=127.0.0.1:20191 10"] # Client retrieves configuration from proxy export CCACHE_REMOTE_CONF=`xcache_monitor -G 127.0.0.1:6666 | tail -1 | grep "SERVER="` # Verify configuration retrieval if [ $? -eq 0 ]; then echo "Proxy configuration retrieved successfully" xcache_client gcc test.c -c -o test.o else echo "Failed to retrieve proxy configuration" fi ``` -------------------------------- ### Deploy Xcache using Docker Source: https://context7.com/ahufan/xcache/llms.txt Provides Dockerfile and commands for building and running xcache in containerized environments. Enables scalable build caching and clustering configurations. ```dockerfile # Build the xcache server image FROM alpine as builder RUN apk add build-base COPY . /opt RUN cd /opt/server && make -j $(nproc) FROM alpine COPY --from=builder /opt/server/xcache /usr/bin/ ENV PORT 20190 EXPOSE $PORT ENTRYPOINT ["/usr/bin/xcache", "-c", "-p", "$PORT", "-m", "1"] ``` ```bash # Build the Docker image docker build -t xcache:latest . # Run xcache server with custom memory and port docker run -d --name xcache1 -p 20190:20190 \ -e PORT=20190 \ xcache:latest -d -c -p 20190 -m 4 # Run multiple instances for clustering docker run -d --name xcache2 -p 20191:20191 xcache:latest -d -c -p 20191 -m 4 docker run -d --name xcache-proxy -p 6666:6666 xcache:latest -d -c -p 6666 -P # Configure cluster after containers start docker exec xcache-proxy xcache_monitor -S localhost:6666["--SERVER=xcache1:20190 10 --SERVER=xcache2:20191 10"] ``` -------------------------------- ### Configuring Proxy Cluster Source: https://context7.com/ahufan/xcache/llms.txt Instructions for setting up a proxy server to manage a cluster of xcache servers with load balancing and retrieving configurations. ```APIDOC ## Configuring Proxy Cluster Set up a proxy server to manage a cluster of xcache servers with load balancing. ### Example 1: Start proxy server ```bash xcache -d -c -p 6666 -P ``` ### Example 2: Configure proxy with backend servers ```bash xcache_monitor -S 127.0.0.1:6666["--SERVER=127.0.0.1:20190 10 --SERVER=127.0.0.1:20191 10"] ``` ### Example 3: Retrieve configuration from proxy ```bash export CCACHE_REMOTE_CONF=`xcache_monitor -G 127.0.0.1:6666 | tail -1 | grep "SERVER="` ``` ### Parameters - `xcache -P`: Starts an xcache instance as a proxy. - `xcache_monitor -S :[]`: Configures backend servers for a proxy. - `xcache_monitor -G :`: Retrieves configuration from a proxy server. ``` -------------------------------- ### Perform Xcache Backups using xcache_monitor Source: https://context7.com/ahufan/xcache/llms.txt Initiates backup operations for xcache servers. Supports resetting the destination before backup or performing a default backup with specified threads. Requires specifying server addresses and ports. ```bash # Backup with reset flag (clear destination before backup) xcache_monitor -b 127.0.0.1:20190,192.168.1.10:20190@8@1 # Default backup with 6 threads, no reset xcache_monitor -b 192.168.1.10:20190,192.168.1.20:20190 ``` -------------------------------- ### Configuring XCACHE Client Source: https://context7.com/ahufan/xcache/llms.txt Environment variables and commands to configure the xcache client to connect to remote xcache servers for distributed caching. ```APIDOC ## Configuring XCACHE Client Configure the client to connect to remote xcache servers for distributed caching. ### Example 1: Single server configuration ```bash export CCACHE_REMOTE_CONF="--SERVER=127.0.0.1:20190 10" ``` ### Example 2: Multiple servers for load balancing ```bash export CCACHE_REMOTE_CONF="--SERVER=127.0.0.1:20190 10 --SERVER=127.0.0.1:20191 10" ``` ### Example 3: Connect through proxy server ```bash export CCACHE_REMOTE_CONF="--PROXY=127.0.0.1:6666" ``` ### Example 4: Compile with remote caching ```bash xcache_client gcc test.c -c -o test.o xcache_client g++ main.cpp -o program -O2 ``` ### Parameters - `CCACHE_REMOTE_CONF`: Environment variable to set client configuration. - `--SERVER=: `: Specifies a remote xcache server and its core value. - `--PROXY=:`: Specifies a proxy server for routing. ``` -------------------------------- ### Configure XCACHE Client for Remote Caching Source: https://context7.com/ahufan/xcache/llms.txt Configures the client to connect to remote xcache servers for distributed caching. Supports single-server, multiple-server load balancing, and proxy server configurations. Demonstrates using xcache_client with compilers. ```bash # Single server configuration with core value export CCACHE_REMOTE_CONF="--SERVER=127.0.0.1:20190 10" # Multiple servers for distributed load balancing export CCACHE_REMOTE_CONF="--SERVER=127.0.0.1:20190 10 --SERVER=127.0.0.1:20191 10" # Connect through proxy server export CCACHE_REMOTE_CONF="--PROXY=127.0.0.1:6666" # Use client to compile with remote caching xcache_client gcc test.c -c -o test.o xcache_client g++ main.cpp -o program -O2 ``` -------------------------------- ### Managing Server Memory Source: https://context7.com/ahufan/xcache/llms.txt Commands to control memory allocation and automatic expansion settings for xcache servers at runtime. ```APIDOC ## Managing Server Memory Control memory allocation and automatic expansion settings at runtime. ### Example 1: Expand memory by 512MB ```bash xcache_monitor -e 127.0.0.1:20190@512 ``` ### Example 2: Disable auto-expand ```bash xcache_monitor -e 127.0.0.1:20190@0 ``` ### Example 3: Enable auto-expand ```bash xcache_monitor -e 127.0.0.1:20190@1 ``` ### Example 4: Expand multiple servers ```bash xcache_monitor -e 127.0.0.1:20190@1024,127.0.0.1:20191@2048 ``` ### Parameters - `xcache_monitor -e @`: Manages server memory. - ``: The IP address and port of the server. - `@`: Amount of memory to expand in MB. Use `0` to disable auto-expand, `1` to enable auto-expand. ``` -------------------------------- ### Manage XCACHE Server Memory at Runtime Source: https://context7.com/ahufan/xcache/llms.txt Controls memory allocation and automatic expansion settings for XCACHE servers at runtime. Allows expanding memory by a specified amount, disabling/enabling auto-expansion, and configuring multiple servers simultaneously. ```bash # Expand server memory by 512MB xcache_monitor -e 127.0.0.1:20190@512 # Disable auto-expand (set to 0) xcache_monitor -e 127.0.0.1:20190@0 # Enable auto-expand (set to 1) xcache_monitor -e 127.0.0.1:20190@1 # Expand multiple servers xcache_monitor -e 127.0.0.1:20190@1024,127.0.0.1:20191@2048 ``` -------------------------------- ### Backing Up Server Data Source: https://context7.com/ahufan/xcache/llms.txt Command to replicate data from one xcache server to another using multi-threaded backup. ```APIDOC ## Backing Up Server Data Replicate data from one server to another with multi-threaded backup. ### Example: Backup from source to destination ```bash xcache_monitor -b 127.0.0.1:20190,127.0.0.1:20191@6@0 ``` ### Parameters - `xcache_monitor -b ,@@`: Initiates data backup. - ``: The IP address and port of the source server. - ``: The IP address and port of the destination server. - `@`: Number of threads to use for backup. - `@`: Reset flag (0=no reset, 1=reset destination before backup). ``` -------------------------------- ### Configuring Prefix Command for Compiler Wrappers Source: https://github.com/ahufan/xcache/blob/master/client/doc/MANUAL.adoc This setting allows ccache to work seamlessly with other compiler wrappers like 'distcc'. By defining 'prefix_command', you instruct ccache to execute the specified wrapper before invoking the actual compiler, ensuring that the wrapper's functionality is utilized. ```bash ccache --set-config prefix_command="distcc" ``` -------------------------------- ### Configuring LRU Parameters Source: https://context7.com/ahufan/xcache/llms.txt Commands to dynamically adjust the Least Recently Used (LRU) cache eviction policies. ```APIDOC ## Configuring LRU Parameters Adjust Least Recently Used cache eviction policies dynamically. ### Example 1: Set LRU parameters (seconds) ```bash xcache_monitor -l 127.0.0.1:20190@50-100-2000-100-2 ``` ### Example 2: Set LRU parameters (days) ```bash xcache_monitor -L 127.0.0.1:20190@2-5-5000-1-2 ``` ### Example 3: Configure multiple servers ```bash xcache_monitor -l 127.0.0.1:20190@30-60-1000-50-2,127.0.0.1:20191@60-120-3000-120-2 ``` ### Parameters - `xcache_monitor -l @----`: Configures LRU with time in seconds. - `xcache_monitor -L @----`: Configures LRU with time in days. - `min`: Minimum time for an item to be considered hot (seconds or days). - `max`: Maximum time for an item to be considered warm (seconds or days). - `count`: Number of items to recycle during an interval. - `interval`: Recycle interval (seconds or days). - `switcher`: LRU eviction mode (0=off, 1=update only, 2=update+recycle). ``` -------------------------------- ### Monitoring Server Statistics Source: https://context7.com/ahufan/xcache/llms.txt Commands to query server statistics and health status for monitoring and diagnostics. ```APIDOC ## Monitoring Server Statistics Query server statistics and health status for monitoring and diagnostics. ### Example 1: Check if servers are alive ```bash xcache_monitor -i 127.0.0.1:20190,127.0.0.1:20191 ``` ### Example 2: Get detailed statistics ```bash xcache_monitor -I 127.0.0.1:20190,127.0.0.1:20191 ``` ### Example 3: Touch servers to verify connectivity ```bash xcache_monitor -t 127.0.0.1:20190,127.0.0.1:20191 ``` ### Parameters - `xcache_monitor -i `: Checks if servers are alive. - `xcache_monitor -I `: Retrieves detailed statistics from servers. - `xcache_monitor -t `: Touches servers to verify connectivity. - ``: Comma-separated list of server addresses (ip:port). ```