skip to Main Content

I use Redis Desktop Manager in windows 10 for caching in ASP.Net Core 3.1 by StackExchange.Redis library.

Except delete and then again add new Key-Value in Redis, is there any way for updating value by key?

3

Answers


  1. You can just do set <key> <value> again and the value will be overwrite.

    Login or Signup to reply.
  2.   using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(""))
        {
           IDatabase db = redis.GetDatabase();
           string age = "11";
           db.StringSet("age", age);
        }
    

    you want to update "age" 25,you can reuse db.StringSet("age", "25");

    Login or Signup to reply.
  3.  var content = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(dto));
     await _cache.SetAsync("Key", content);
    

    dto is the value sent by Action

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search