|
| 1 | +# Basic cluster configuration |
| 2 | + |
| 3 | +for installation, look at our [Installation guide](../installation.md) |
| 4 | + |
| 5 | + |
| 6 | +## Configure as cache backend |
| 7 | + |
| 8 | +to start using django-valkey's cluster backend, change your django cache setting to something like this: |
| 9 | + |
| 10 | +```python |
| 11 | +CACHES = { |
| 12 | + "default": { |
| 13 | + "BACKEND": "django_valkey.cluster_cache.cache.ClusterValkeyCache", |
| 14 | + "LOCATION": "valkey://127.0.0.1:6379", |
| 15 | + "OPTIONS": {...} |
| 16 | + } |
| 17 | + } |
| 18 | +``` |
| 19 | + |
| 20 | +you need to point to at least one of the cluster nodes in `LOCATION`, or pass a list of multiple nodes |
| 21 | + |
| 22 | +at the moment, only one client is avilable for cluster backend |
| 23 | + |
| 24 | +most of the configurations you see in [basic configuration](../configure/basic_configurations.md) and [advanced configuration](../configure/advanced_configurations.md) |
| 25 | +apply here as well, except the following: |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +### Memcached exception behavior |
| 30 | +in [Memcahed exception behavior](../configure/basic_configurations.md#memcached-exception-behavior) we discussed how to ignore and log exceptitions, |
| 31 | +sadly, until we find a way around it, this is not accessable with cluster backend |
| 32 | + |
| 33 | + |
| 34 | +## Multi-key Commands |
| 35 | + |
| 36 | +please refer to [valkey-py docs](https://valkey-py.readthedocs.io/en/latest/clustering.html#multi-key-commands) on how to use multi-key commands, such as `mset`, `megt`, etc... |
| 37 | + |
| 38 | +there are some other info in their documentations that might be of interest to you, we suggest you take a look |
| 39 | + |
| 40 | + |
| 41 | +## Additional methods |
| 42 | +in addition to what other `django-valkey` clients provide, cluster client supports the following methods: |
| 43 | + |
| 44 | +* mset_nonatomic (same as `set_many`) |
| 45 | +* msetnx |
| 46 | +* mget_nonatomic (same as `get_many`) |
| 47 | +* readonly |
| 48 | +* readwrite |
| 49 | +* keyslot |
| 50 | +* flushall |
| 51 | +* invalidate_key_from_cache |
0 commit comments