In a standard configuration of a Redis cluster, all writes need to be made to the primary (master) nodes. This is because Redis uses a master-slave replication model where the data is consistently replicated from master nodes to slave nodes for high availability and failover purposes.
Although it's technically possible to write directly to a slave node, doing so is highly discouraged and generally not recommended. The reason is that any data written directly to a slave will be overwritten during the next synchronization with its master.
Let's take an example:
Even if you successfully write to a slave node and retrieve the value as shown above, this change won't propagate to other nodes in the cluster. Once the slave synchronizes with its master, your changes will be lost.
The idea behind this architecture is to maintain consistent data across the entire cluster. In case the master goes down, a slave can take over without any data loss, thereby providing fault tolerance and high availability.