RedisTemplate做队列,行进先出

  @Test
    public void contextLoads() {
        redisTemplate.opsForList().leftPush("errorSchedule","v1");
        redisTemplate.opsForList().leftPush("errorSchedule","v2");
        redisTemplate.opsForList().leftPush("errorSchedule","v3");
        Object errorSchedule = redisTemplate.opsForList().index("errorSchedule", 0);
        Object errorSchedule1 = redisTemplate.opsForList().index("errorSchedule", 1);
        Object errorSchedule2 = redisTemplate.opsForList().index("errorSchedule", 2);
        System.out.println("00000     "+errorSchedule);
        System.out.println("11111      "+errorSchedule1);
        System.out.println("222222      "+errorSchedule2);
        Object o = redisTemplate.opsForList().rightPop("errorSchedule");
        System.out.println("------------------------------------------------");
        Object errorSchedulea = redisTemplate.opsForList().index("errorSchedule", 0);
        Object errorSchedule1b = redisTemplate.opsForList().index("errorSchedule", 1);
        Object errorSchedule2c = redisTemplate.opsForList().index("errorSchedule", 2);
        System.out.println("00000     "+errorSchedulea);
        System.out.println("11111      "+errorSchedule1b);
        System.out.println("222222      "+errorSchedule2c);

    }

RedisTemplate做队列,行进先出_第1张图片

RedisTemplate做队列,行进先出_第2张图片

你可能感兴趣的:(spring,reids)