Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-1002

redisTemplate hscan count can not limit fetch data size

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: 2.1.9 (Lovelace SR9)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Sprint:
      Moore RC2

      Description

             redisTemplate.delete("testKey");
      
              for (int i = 0; i < 9000; i++) {
                  Person p = new Person();
                  p.setAge(i+"");
                  p.setName("name"+i);
                  redisTemplate.opsForHash().put("testKey","hkey_"+i,p);
              }
              List<Object> testKey = redisTemplate.opsForHash().values("testKey");
      
      
              Cursor<Map.Entry<Object, Object>> entryCursor = redisTemplate.opsForHash().scan("testKey", ScanOptions.scanOptions().match("*").count(500).build());
              List<String> keys  = new ArrayList<>(500);
              int i = 0;
      
      
              while(entryCursor.hasNext() && !entryCursor.isClosed()){
                  Map.Entry<Object, Object> next = entryCursor.next();
                  keys.add(next.getKey().toString());
                  System.out.println(next.getValue().toString());
                  i++;
              }
      
              entryCursor.close();
      
              Assert.assertTrue( i == 500);//will not pass 
       
              redisTemplate.opsForHash().put("testKey","hkey_nodel", new Person());
      
              redisTemplate.opsForHash().delete("testKey",keys.toArray());
      
      
              //List<Object> list = redisTemplate.opsForHash().values("testKey");
      
             // Assert.assertTrue(list.size() == 1);
      

       the i will be 900 ,expect 500 

        Attachments

          Activity

            People

            • Assignee:
              cstrobl Christoph Strobl
              Reporter:
              seven4x Seven4X
              Last updater:
              Christoph Strobl
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: