public RedisRegistryProvider() { if (SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration == null) throw new Exception("注册中心配置有误"); string url = SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.Url; string collectionName = "RegistryData"; var attrs = DictionaryUtils.GetFromConfig(SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.AddtionalFields); if (attrs != null && attrs.ContainsKey(AttrKeys.Registry_RedisCollectionName) ) { if (!string.IsNullOrEmpty(attrs[AttrKeys.Registry_RedisCollectionName])) { collectionName = attrs[AttrKeys.Registry_RedisCollectionName]; } } _redisClient = new RedisClient(url); _typedClient = _redisClient.As<RegistryDataInfo>(); _table = _typedClient.Lists[collectionName]; _redisSubscription = _redisClient.CreateSubscription(); _redisSubscription.OnMessage += (channel, msg) => { var data = _serializer.Deserialize<ServiceRegistryMetta>(msg); if (this.ServiceChanged == null) return; this.ServiceChanged(this, new ServiceNotifyEventArgs { Data = data }); }; }
public RedisQueueService(Uri baseUri, bool resume) { using (RedisClient redisClient = new RedisClient()) { _redis = redisClient.GetTypedClient<Entry>(); _queue = _redis.Lists[string.Format("barcodes:{0}:queue", baseUri)]; if (!resume) { _queue.Clear(); } } }
public void SetUp() { if (client != null) { client.Dispose(); client = null; } client = new RedisClient(TestConfig.SingleHost); client.FlushAll(); redis = client.GetTypedClient<CustomType>(); List = redis.Lists[ListId]; List2 = redis.Lists[ListId2]; }
public int GetListCount(IRedisList <T> fromList) { return(client.LLen(fromList.Id)); }
public T GetItemFromList(IRedisList <T> fromList, int listIndex) { return(DeserializeValue(client.LIndex(fromList.Id, listIndex))); }
public int RemoveItemFromList(IRedisList <T> fromList, T value) { const int removeAll = 0; return(client.LRem(fromList.Id, removeAll, SerializeValue(value))); }
public int RemoveItemFromList(IRedisList <T> fromList, T value, int noOfMatches) { return(client.LRem(fromList.Id, noOfMatches, SerializeValue(value))); }
public void InsertAfterItemInList(IRedisList <T> toList, T pivot, T value) { client.LInsert(toList.Id, insertBefore: false, pivot: SerializeValue(pivot), value: SerializeValue(value)); }
public T BlockingPopAndPushItemBetweenLists(IRedisList <T> fromList, IRedisList <T> toList, TimeSpan?timeOut) { return(DeserializeValue(client.BRPopLPush(fromList.Id, toList.Id, (int)timeOut.GetValueOrDefault().TotalSeconds))); }
public void PrependItemToList(IRedisList <T> fromList, T value) { client.LPush(fromList.Id, SerializeValue(value)); }
public void PushItemToList(IRedisList <T> fromList, T item) { client.RPush(fromList.Id, SerializeValue(item)); }
private void AddValueToList(IRedisList list, T value) => list.Add(this.Serialize(value));
private bool RemoveValueFromList(IRedisList list, T value) => list.Remove(this.Serialize(value));
public string PopAndPush(IRedisList toList) { return(client.PopAndPushItemBetweenLists(listId, toList.Id)); }
public List <T> GetRangeFromList(IRedisList <T> fromList, int startingFrom, int endingAt) { var multiDataList = client.LRange(fromList.Id, startingFrom, endingAt); return(CreateList(multiDataList)); }
public List <T> GetAllItemsFromList(IRedisList <T> fromList) { var multiDataList = client.LRange(fromList.Id, FirstElement, LastElement); return(CreateList(multiDataList)); }
public void SetItemInList(IRedisList <T> toList, int listIndex, T value) { client.LSet(toList.Id, listIndex, SerializeValue(value)); }
public T RemoveEndFromList(IRedisList <T> fromList) { return(DeserializeValue(client.RPop(fromList.Id))); }
public void EnqueueItemOnList(IRedisList <T> fromList, T item) { client.LPush(fromList.Id, SerializeValue(item)); }
public string PopAndPush(IRedisList toList) { return client.PopAndPushItemBetweenLists(listId, toList.Id); }
public T PopItemFromList(IRedisList <T> fromList) { return(DeserializeValue(client.RPop(fromList.Id))); }
public T PopAndPush(IRedisList <T> toList) { return(client.PopAndPushItemBetweenLists(this, toList)); }
public void RemoveAllFromList(IRedisList <T> fromList) { client.LTrim(fromList.Id, int.MaxValue, FirstElement); }
public T PopAndPushItemBetweenLists(IRedisList <T> fromList, IRedisList <T> toList) { return(DeserializeValue(client.RPopLPush(fromList.Id, toList.Id))); }
public void TrimList(IRedisList <T> fromList, int keepStartingFrom, int keepEndingAt) { client.LTrim(fromList.Id, keepStartingFrom, keepEndingAt); }
public T BlockingPopAndPush(IRedisList <T> toList, TimeSpan?timeOut) { return(client.BlockingPopAndPushItemBetweenLists(this, toList, timeOut)); }