c# - Stackexchange.Redis ListRightPush "Invalid number of arguments"

标签 c# redis stackexchange.redis

我正在尝试批量保存到 redis 列表中。它适用于一批,但对于两个,我得到一个异常,说我的参数数量无效。这是我的代码:

List<RedisValue> toWrite = new List<RedisValue>(batchSize);
UserRequest r;
while (toWrite.Count < batchSize && _saveQueque.TryDequeue(out r))
{
     toWrite.Add(Serialize(r));
}

if (toWrite.Count > 0)
{
     GetDB().ListRightPush(key, toWrite.ToArray()); //Throws exception
     GetDB().KeyExpire(key, DateTime.Now.AddHours(4), CommandFlags.FireAndForget);
}

我在这里做错了什么?


会不会是我的序列化方案中的空终止符?

最佳答案

听起来您使用的是旧版本的 redis; rpush 的多值(varadic)版本已添加到 redis v2.4 中 - 您至少需要该版本才能使用此 API。

关于c# - Stackexchange.Redis ListRightPush "Invalid number of arguments",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48813722/

相关文章:

c# - 使用循环构建 Where 子句并将每个迭代与 OR 连接

c# - 小娜 VCD : set command's Navigate target to a Page in a subfolder

c# - Windows Media Player 嵌入 C# 视频速度变化

session - 在 nodejs/redis 中保存 tcp session ?

redis - 预订引擎 |雷迪斯

.net-core - 除了从本地主机无法连接到Redis

c# - 如何在 C# 中获取 Mac OSX 当前用户的目录?

python-3.x - Python 3.7、Ubuntu 16.04 中的 Celery 任务未注册异常

ruby-on-rails - Sidekiq 作业已安排,未运行,只是消失了

c# - Redis 字典倒序查找