Skip to content

RedisCache update in .NET 6 breaks usage against older redis servers #38715

@mgravell

Description

@mgravell

Timeline:

  • redis 2.0 had HSET key field value for setting individual hash fields, and HMSET key field value [field value ...] for setting multiple hash fields (against the same key); as you can see, there's a lot of overlap here
  • redis 4.0 observes this redundancy, and adds HSET key field value [field value ...], and also marks HMSET as deprecated, although it still works fine
  • RedisCache wants to set a hash with 3 fields against a single key; historically it has used HMSET for this (via Lua)
  • .NET 6 switches to using the non-deprecated HSET API

Impact:

For users targeting redis versions that lack the varadic HSET (so: versions before 4.0), it simply doesn't work, manifesting in a RedisServerException:

Wrong number of args calling Redis command From Lua script

Suggestions:

  1. check the redis server version (APIs exist on SE-Redis for this) before deciding which to use
  2. or, just use HMSET; it hasn't gone anywhere, and is honestly: unlikely to go anywhere
  3. make 3 simple calls to HSET, which would work everywhere and still be contiguous (thanks to the single-threaded core) - although I confess that this is inelegant

A complicating factor is that the Redis-64 port of Redis on Windows by Microsoft (now abandoned): stops at 3.0.503. Alternatives for Windows hosting are WSL or Memurai (commercial), or containers such as Docker. This means that some folks have (perhaps unwisely) stagnated on v3, wanting to keep things simple.

Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionshelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions