Search code examples
phplaravelredislumenpredis

Using Redis clusters and transactions


While using Redis cluster I get the following error:

Cannot use 'MULTI' with redis-cluster.

With the just the following call:

Redis::multi();

Is there a way to ensure data integrity across the clusters without the use of transactions, since that is not possible


Solution

  • Redis doesn't support transaction, if keys are located on different slots/nodes.

    If you have to store your data in a cluster, you must ensure all keys related to your transaction are stored on a single slot. You can use hash tag to do that.

    Then you can take the node holding the slot as a single Redis instance, and run transaction on that node.