Esempio n. 1
0
 protected override Message CreateMessage(long cursor)
 {
     if (CursorUtils.IsNil(pattern))
     {
         if (pageSize == CursorUtils.DefaultPageSize)
         {
             return(Message.Create(db, flags, RedisCommand.SCAN, cursor));
         }
         else
         {
             return(Message.Create(db, flags, RedisCommand.SCAN, cursor, RedisLiterals.COUNT, pageSize));
         }
     }
     else
     {
         if (pageSize == CursorUtils.DefaultPageSize)
         {
             return(Message.Create(db, flags, RedisCommand.SCAN, cursor, RedisLiterals.MATCH, pattern));
         }
         else
         {
             return(Message.Create(db, flags, RedisCommand.SCAN, cursor, RedisLiterals.MATCH, pattern, RedisLiterals.COUNT, pageSize));
         }
     }
 }
Esempio n. 2
0
        public IEnumerable <RedisKey> Keys(int database = 0, RedisValue pattern = default(RedisValue), int pageSize = CursorUtils.DefaultPageSize, long cursor = CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None)
        {
            if (pageSize <= 0)
            {
                throw new ArgumentOutOfRangeException("pageSize");
            }
            if (CursorUtils.IsNil(pattern))
            {
                pattern = RedisLiterals.Wildcard;
            }

            if (multiplexer.CommandMap.IsAvailable(RedisCommand.SCAN))
            {
                var features = server.GetFeatures();

                if (features.Scan)
                {
                    return(new KeysScanEnumerable(this, database, pattern, pageSize, cursor, pageOffset, flags));
                }
            }

            if (cursor != 0 || pageOffset != 0)
            {
                throw ExceptionFactory.NoCursor(RedisCommand.KEYS);
            }
            Message msg = Message.Create(database, flags, RedisCommand.KEYS, pattern);

            return(ExecuteSync(msg, ResultProcessor.RedisKeyArray));
        }