有没有办法更新 Redis 中的值?
Is there any way to update value in Redis?
我在 windows 10 中使用 Redis 桌面管理器,通过 StackExchange.Redis
库在 ASP.Net Core 3.1 中进行缓存。
除了在Redis中删除然后重新添加新的Key-Value,还有什么方法可以通过key更新value吗?
您可以再执行一次 set <key> <value>
,该值将被覆盖。
using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(""))
{
IDatabase db = redis.GetDatabase();
string age = "11";
db.StringSet("age", age);
}
你想更新"age" 25,你可以重复使用db.StringSet("age", "25");
var content = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(dto));
await _cache.SetAsync("Key", content);
dto是Action发送的值
我在 windows 10 中使用 Redis 桌面管理器,通过 StackExchange.Redis
库在 ASP.Net Core 3.1 中进行缓存。
除了在Redis中删除然后重新添加新的Key-Value,还有什么方法可以通过key更新value吗?
您可以再执行一次 set <key> <value>
,该值将被覆盖。
using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(""))
{
IDatabase db = redis.GetDatabase();
string age = "11";
db.StringSet("age", age);
}
你想更新"age" 25,你可以重复使用db.StringSet("age", "25");
var content = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(dto));
await _cache.SetAsync("Key", content);
dto是Action发送的值