dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.02k forks source link

Garnet Microsoft.Extensions.Caching “ERR unknown command” #55594

Closed YataoFeng closed 6 months ago

YataoFeng commented 6 months ago

Is there an existing issue for this?

Describe the bug

I am using Microsoft.Extensions.Caching The following error occurred during StackExchangeRedis. StackExchange.Redis.RedisServerException:“ERR unknown command” image

Expected Behavior

No response

Steps To Reproduce

https://[raw.githubusercontent.com/microsoft/garnet/main/docker-compose.yml](https://raw.githubusercontent.com/microsoft/garnet/main/docker-compose.yml)

services:
  garnet:
    image: 'ghcr.io/microsoft/garnet'
    ulimits:
      memlock: -1
    ports:
      - "6379:6379"
    # To avoid docker NAT, consider `host` mode.
    # https://docs.docker.com/compose/compose-file/compose-file-v3/#network_mode
    # network_mode: "host"
    volumes:
      - garnetdata:/data
volumes:
  garnetdata:
using Microsoft.Extensions.Caching.Distributed;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddStackExchangeRedisCache(options =>
{
    options.Configuration = "localhost:6379";
    options.InstanceName = "garnet";
});
var app = builder.Build();

IDistributedCache distributedCache = app.Services.GetRequiredService<IDistributedCache>();

distributedCache.SetString("test", "hello garnet");

var value = distributedCache.GetString("test");

if (value != "hello garnet")
{
    throw new Exception();
}
app.Run();

Exceptions (if any)

No response

.NET Version

dotnet 8

Anything else?

No response

gfoidl commented 6 months ago

@mgravell PTAL.

mgravell commented 6 months ago

@gfoidl @YataoFeng this is already addressed in .NET 9 Preview 4 (which includes down-level TFM support) via https://github.com/dotnet/aspnetcore/pull/54689

mgravell commented 6 months ago

Closing as duplicate of https://github.com/dotnet/aspnetcore/issues/54685