- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
有没有一种方法可以通过 StackExchange.Redis 在 Redis 中执行 MSET
。
引用后documentation , 下面我写的代码是执行 StringSetAsync
来在 Redis 中添加多个键值对。我们有类似 IDatabase.StringSet(RedisKey[], RedisValue[])
的东西吗?
public void Add(IEnumerable<CacheKeyValue> cacheKeyValues)
{
var tasks = new List<Task>();
foreach(var kv in cacheKeyValues.ToList())
{
tasks.Add(((Task<bool>)DB.StringSetAsync(kv.Key, ((RedisValue)kv.Value))).ContinueWith((b) => kv.Status = true));
}
Task.WaitAll(tasks.ToArray());
}
最佳答案
你想调用:
bool StringSet(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);
但只传递第一个参数(这意味着第二个和第三个参数是默认值,这意味着您将获得 MSET
行为)。
/// <summary>
/// Sets the given keys to their respective values. If "not exists" is specified, this will not perform any operation at all even if just a single key already exists.
/// </summary>
/// <returns>True if the keys were set, else False</returns>
/// <remarks>http://redis.io/commands/mset</remarks>
/// <remarks>http://redis.io/commands/msetnx</remarks>
bool StringSet(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);
还有一个 async
等价物:
/// <summary>
/// Sets the given keys to their respective values. If "not exists" is specified, this will not perform any operation at all even if just a single key already exists.
/// </summary>
/// <returns>True if the keys were set, else False</returns>
/// <remarks>http://redis.io/commands/mset</remarks>
/// <remarks>http://redis.io/commands/msetnx</remarks>
Task<bool> StringSetAsync(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);
关于c# - StackExchange.Redis 中的 MSET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45237837/
MSets 似乎是 OCaml 风格的有限集的方法。可悲的是,我找不到示例用途。 我如何定义一个空的 MSet或单例 MSet ?我怎样才能联合两个MSets一起? 最佳答案 让我展示一个有限自然数集
这是我的代码: const Redis = require('ioredis'); const client = new Redis(); // multi set client.mset({'key
有没有一种方法可以通过 StackExchange.Redis 在 Redis 中执行 MSET。 引用后documentation , 下面我写的代码是执行 StringSetAsync 来在 Re
我目前正在使用 memcached,但我正在尝试将此机制转移到 redis。 我的目标是每 1000 次迭代保存整个数组(键 => 值)。 旧的解决方案: 'value1', 'key2'
FSets 的文档和 MSets表明它们是非常相似的结构。它们有什么不同? 最佳答案 根据library说明, MSets是“FSets 的现代化”,我怀疑是为了向后兼容而保留的。 关于set - C
我可以使用 SET 命令设置 key 的过期时间,如下所示: redis->executeCommand('SET',['key','value','EX',10000]); 我尝试使用 MSET 命
有没有办法将 MSET 用于 HSET key ?我试图在一次操作中更新多个 HSET key (不是字段)以节省网络流量。 最佳答案 不,是。 不,MSET 不支持此行为,Redis 也没有执行此操
我正在编写一个与 REDIS 交互的 C# 应用程序(通过 C# REDIS 客户端接口(interface),例如 ServiceStack/BookSleeve)。 我正在寻找有关如何最有效地将两
我将 java 与 lettuce redis 客户端一起使用。我有一个本地 Redis 实例,我正在读取一个文件并将 400,000 个条目放入 HashMap 中。但是在 mset 过程结束后,没
我有一个 Spring Boot 应用程序需要获取数百万个键值对并将它们插入 Redis。 目前我正在使用 multiSet 方法一次处理 1,000 个键值对。 @Autowired private
我是一名优秀的程序员,十分优秀!