Skip to content

RedisCluster::eval() error: All keys do not map to the same slot when flushing tagged cache #57202

@joostdebruijn

Description

@joostdebruijn

Laravel Version

12.31.1

PHP Version

8.4.7

Database Driver & Version

Redis 7.1 Serverless

Description

After the recent PR that atomically flushes Redis cache tags (#57098), calling flush() on a tagged cache using a Redis Cluster now throws the error:

RedisCluster::eval(): All keys do not map to the same slot

It appears that the atomic flush implementation is trying to run EVAL on multiple keys that are not in the same Redis slot. In Redis Cluster, all keys passed to an EVAL command must be in the same hash slot, or the command will fail with this error.

This makes it impossible to flush tagged cache in a Redis Cluster setup after the PR. I'm running my application on Laravel Vapor.

Steps To Reproduce

  1. Set up Laravel with a Redis Cluster and use Redis as the cache driver.
  2. Use tagged cache (Cache::tags([...])->flush()).
  3. Observe that the error is thrown: RedisCluster::eval(): All keys do not map to the same slot.
  4. This happens only after updating to a version 12.30 or higher

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions