Redis有什么方法可以更新价值吗?

问题描述

我使用Windows 10中的Redis Desktop Manager通过StackExchange.Redis库在ASP.Net Core 3.1中进行缓存。

除了在Redis中删除然后再次添加新的键值外,还有什么方法可以通过键来更新值吗?

解决方法

您可以再次执行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”);

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...