Exemplo n.º 1
0
        public Task SaveItems(IDatabaseAsync database, IDataKey key, params RedisValue[] redisValues)
        {
            var redisKey = link.GetKey(key);

            logger.LogTrace("SaveItems: <{0}>", key);

            var tasks = new List <Task>(mainIndexManager.Add(database, key));
            var size  = GetLimit(key);

            if (size.HasValue)
            {
                var list = redisValues.ToList();
                list.Add(size.Value);
                tasks.Add(database.ScriptEvaluateAsync(
                              link.Generator.GenerateInsertScript(true, redisValues.Length),
                              new[] { redisKey },
                              list.ToArray()));
            }
            else
            {
                tasks.Add(database.ListRightPushAsync(redisKey, redisValues));
            }

            return(Task.WhenAll(tasks));
        }
Exemplo n.º 2
0
        private long?GetLimit(IDataKey key)
        {
            var repository            = key as RepositoryKey;
            var limitedSizeRepository = repository?.Repository as ILimitedSizeRepository;

            return(limitedSizeRepository?.Size);
        }
Exemplo n.º 3
0
        public ISubscriber SubscribeKeyEvents(IDataKey key, Action <KeyspaceEvent> action)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var typeKey = this.GetKey(key);

            return(Multiplexer.SubscribeKeyEvents(typeKey, action));
        }