/// <summary> /// 根据IEnumerable数据添加链表 /// </summary> /// <typeparam name="T">对象类型</typeparam> /// <param name="key">键</param> /// <param name="values">值</param> /// <param name="timeout">过期时间(秒),-1:不过期;0:默认过期时间:一天;有效具体秒数</param> public void AddList <T>(string key, IEnumerable <T> values, int timeout = -1) { try { IRedisTypedClient <T> iredisClient = base.redisClient.As <T>(); IRedisList <T> redisList = iredisClient.Lists[key]; redisList.AddRange(values); if (timeout > 0) { if (timeout > 0) { this.secondsTimeOut = timeout; } var dtTimeOut = DateTime.Now.AddSeconds(this.secondsTimeOut); base.redisClient.ExpireEntryAt(key, dtTimeOut); } iredisClient.Save(); } catch (Exception ex) { string message = string.Format("添加链表出错"); LOG.Error(ex, message); } }
public void Add(List <T> entities) { using (var redisClient = new RedisClient()) { IRedisTypedClient <T> redis = redisClient.As <T>(); IRedisList <T> list = redis.Lists["asa." + _cacheKey + ".all"]; list.AddRange(entities); } }
/// <summary> /// Add list to redis caching server /// </summary> /// <typeparam name="T"></typeparam> public static void AddList <T>(List <T> listNew) { using (var redis = new RedisClient(Host)) { IRedisTypedClient <T> redisObject = redis.As <T>(); var redisObjectName = typeof(T).Name; IRedisList <T> listObject = redisObject.Lists[redisObjectName]; listObject.AddRange(listNew); } }
/// <summary> /// 根据IEnumerable数据添加链表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="listId"></param> /// <param name="values"></param> /// <param name="timeout"></param> public void AddList <T>(string listId, IEnumerable <T> values, int timeout = 0) { Redis.Expire(listId, 60); IRedisTypedClient <T> iredisClient = Redis.As <T>(); if (timeout > 0) { Redis.Expire(listId, timeout); } IRedisList <T> redisList = iredisClient.Lists[listId]; redisList.AddRange(values); iredisClient.Save(); }
/// <summary> /// 根据IEnumerable数据添加链表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="listId"></param> /// <param name="values"></param> /// <param name="timeout"></param> public void AddList <T>(string listId, IEnumerable <T> values, int timeout = 0) { IRedisTypedClient <T> iredisClient = Redis.As <T>(); IRedisList <T> redisList = iredisClient.Lists[listId]; redisList.AddRange(values); if (timeout >= 0) { if (timeout == 0) { timeout = secondsTimeOut; } Redis.ExpireEntryIn(listId, TimeSpan.FromSeconds(timeout)); } iredisClient.Save(); }
/// <summary> /// 添加需要回执的进仓单信息到Redis /// </summary> /// <param name="lstRInStore">进仓单回执信息列表</param> private static void AddInStoreInfo(List <InStoreReceipt> inStoreReceipt) { IRedisList <InStoreReceipt> rlstRInStore = redis.Lists["InStoreReceiptInfoList"]; rlstRInStore.AddRange(inStoreReceipt); }