Example #1
0
        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];
        }
Example #4
0
 public int GetListCount(IRedisList <T> fromList)
 {
     return(client.LLen(fromList.Id));
 }
Example #5
0
 public T GetItemFromList(IRedisList <T> fromList, int listIndex)
 {
     return(DeserializeValue(client.LIndex(fromList.Id, listIndex)));
 }
Example #6
0
        public int RemoveItemFromList(IRedisList <T> fromList, T value)
        {
            const int removeAll = 0;

            return(client.LRem(fromList.Id, removeAll, SerializeValue(value)));
        }
Example #7
0
 public int RemoveItemFromList(IRedisList <T> fromList, T value, int noOfMatches)
 {
     return(client.LRem(fromList.Id, noOfMatches, SerializeValue(value)));
 }
Example #8
0
 public void InsertAfterItemInList(IRedisList <T> toList, T pivot, T value)
 {
     client.LInsert(toList.Id, insertBefore: false, pivot: SerializeValue(pivot), value: SerializeValue(value));
 }
Example #9
0
 public T BlockingPopAndPushItemBetweenLists(IRedisList <T> fromList, IRedisList <T> toList, TimeSpan?timeOut)
 {
     return(DeserializeValue(client.BRPopLPush(fromList.Id, toList.Id, (int)timeOut.GetValueOrDefault().TotalSeconds)));
 }
Example #10
0
 public void PrependItemToList(IRedisList <T> fromList, T value)
 {
     client.LPush(fromList.Id, SerializeValue(value));
 }
Example #11
0
 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));
Example #14
0
 public string PopAndPush(IRedisList toList)
 {
     return(client.PopAndPushItemBetweenLists(listId, toList.Id));
 }
Example #15
0
        public List <T> GetRangeFromList(IRedisList <T> fromList, int startingFrom, int endingAt)
        {
            var multiDataList = client.LRange(fromList.Id, startingFrom, endingAt);

            return(CreateList(multiDataList));
        }
Example #16
0
        public List <T> GetAllItemsFromList(IRedisList <T> fromList)
        {
            var multiDataList = client.LRange(fromList.Id, FirstElement, LastElement);

            return(CreateList(multiDataList));
        }
Example #17
0
 public void SetItemInList(IRedisList <T> toList, int listIndex, T value)
 {
     client.LSet(toList.Id, listIndex, SerializeValue(value));
 }
Example #18
0
 public T RemoveEndFromList(IRedisList <T> fromList)
 {
     return(DeserializeValue(client.RPop(fromList.Id)));
 }
Example #19
0
 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);
		}
Example #21
0
 public T PopItemFromList(IRedisList <T> fromList)
 {
     return(DeserializeValue(client.RPop(fromList.Id)));
 }
Example #22
0
 public T PopAndPush(IRedisList <T> toList)
 {
     return(client.PopAndPushItemBetweenLists(this, toList));
 }
Example #23
0
 public void RemoveAllFromList(IRedisList <T> fromList)
 {
     client.LTrim(fromList.Id, int.MaxValue, FirstElement);
 }
Example #24
0
 public T PopAndPushItemBetweenLists(IRedisList <T> fromList, IRedisList <T> toList)
 {
     return(DeserializeValue(client.RPopLPush(fromList.Id, toList.Id)));
 }
Example #25
0
 public void TrimList(IRedisList <T> fromList, int keepStartingFrom, int keepEndingAt)
 {
     client.LTrim(fromList.Id, keepStartingFrom, keepEndingAt);
 }
Example #26
0
 public T BlockingPopAndPush(IRedisList <T> toList, TimeSpan?timeOut)
 {
     return(client.BlockingPopAndPushItemBetweenLists(this, toList, timeOut));
 }