> For the complete documentation index, see [llms.txt](https://docs.xandtech.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xandtech.fr/home/xplayercurrencies/integrations/cross-server-redis.md).

# Cross-Server Sync (Redis)

Optional real-time balance sync across several servers sharing the same MySQL database (a network). Without it, another server only sees a balance change once the player quits and rejoins there - with it, a change on one server instantly updates the in-memory balance of any other server where that player happens to be online, via Redis pub/sub.

{% hint style="warning" %}
Only takes effect when `storage.type` is `MYSQL` (see [Installation](/home/xplayercurrencies/getting-started/installation.md#choosing-a-storage-backend)) - every server on the network must point at the **same** MySQL database. If `storage.type` isn't `MYSQL`, this section is safely ignored with a warning.
{% endhint %}

## Setup

In `config.yml`, on every server sharing the network:

```yaml
storage:
  type: MYSQL
  mysql:
    host: your-shared-mysql-host
    # ...

cross-server:
  enabled: true
  redis:
    host: localhost
    port: 6379
    password: ""
    database: 0
    channel: xplayercurrencies:balance-sync
```

| Key             | Description                                                                                                                                      |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `redis.channel` | The pub/sub channel name - only needs changing if multiple, unrelated XPlayerCurrencies networks happen to share the same Redis server/database. |

This is hot-swappable on `/currencies admin reload` (unlike `storage.type` itself, which needs a restart).

## What it does (and doesn't) do

* A balance change is still written to the shared MySQL database first (the source of truth) - Redis only pushes the **in-memory** update to other servers so they don't have to wait for the player to reconnect there to see it.
* Every read-modify-write against MySQL is still transactionally safe on its own even without Redis - this feature is purely about **visibility latency**, not correctness.
* No Redis connection needed for a single standalone server - leave `cross-server.enabled: false` (the default).

Next: [API & Events](/home/xplayercurrencies/developer/api.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xandtech.fr/home/xplayercurrencies/integrations/cross-server-redis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
