Spring RedisTemplate操作-通道操作(10)

2018/06/08 09:09
阅读数 70
    @Autowired
    @Resource(name = "redisTemplate")
    private RedisTemplate<String, String> rt;

    public void flushdb() {
        rt.execute(new RedisCallback<Object>() {
            public String doInRedis(RedisConnection connection) throws DataAccessException {
                connection.flushDb();
                return "ok";
            }
        });
    }

    public void set() {
        flushdb();
        rt.opsForValue().set("a", "1");
        List<Object> results = rt.executePipelined(new RedisCallback<Object>() {
            public Object doInRedis(RedisConnection connection) throws DataAccessException {
                for (int i = 0; i < 10; i++) {
                    connection.incr("a".getBytes());
                }
                return null;
            }
        });
        System.out.println(rt.opsForValue().get("a"));
    }
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部