Redis实战之HyperLogLog统计

Redis实战之HyperLogLog统计

在这里插入图片描述
在这里插入图片描述

 @Test
    void testHyperLogLog() {
    
    
        String[] values = new String[1000];
        int j = 0;
        for (int i = 0; i < 1000000; i++) {
    
    
            j = i % 1000;
            values[j] = "user_" + i;
            if(j == 999){
    
    
                // 发送到Redis
                stringRedisTemplate.opsForHyperLogLog().add("hl2", values);
            }
        }
        // 统计数量
        Long count = stringRedisTemplate.opsForHyperLogLog().size("hl2");
        System.out.println("count = " + count);
    }
}

猜你喜欢

转载自blog.csdn.net/hcyxsh/article/details/131034518
今日推荐