2881099 / csredis

.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
MIT License
2.01k stars 414 forks source link

使用RedisHelper.MSet() 函数异常。 #263

Open herson-he opened 4 years ago

herson-he commented 4 years ago

var listAdminInfo = context.AdminInfo.AsNoTracking().ToList(); listAdminInfo = listAdminInfo == null ? new List() : listAdminInfo; KeyValuePair<string, string>[] arrKeyValue = new KeyValuePair<string, string>[listAdminInfo.Count()]; for (int i = 0; i < arrKeyValue.Length; i++) { KeyValuePair<string, string> keyValue = new KeyValuePair<string, string>(ManagerInfoCacheKeyPrefix + listAdminInfo[i].UserID, JsonConvert.SerializeObject(listAdminInfo[i])); arrKeyValue[i] = keyValue; } if (listAdminInfo.Count > 0) { RedisHelper.MSet(arrKeyValue); //RedisHelper.SAdd(ManagerIDListCacheKey, listAdminInfo.Select(a => a.UserID).ToArray()); }

异常信息: System.Exception:“keyValues 参数是键值对,不应该出现奇数(数量),请检查使用姿势。”

2881099 commented 4 years ago

object[] kv = new object[] { "key1", "value1", "key2", "value2", "key3", "value3" }

herson-he commented 4 years ago

object[] kv = new object[] { "key1", "value1", "key2", "value2", "key3", "value3" }

可以了,谢谢。