Skip to content

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

Closed
@YataoFeng

Description

@YataoFeng

Is there an existing issue for this?

  • I have searched the existing issues

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-cachingIncludes: StackExchangeRedis and SqlServer distributed caches

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions