码迷,mamicode.com
首页 > 编程语言 > 详细

Spring RedisTemplate操作-HyperLogLog操作(7)

时间:2017-04-25 11:44:09      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:ati   code   get   private   bag   tuple   val   int   type   

@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();
        HyperLogLogOperations<String, String> vo = rt.opsForHyperLogLog();
        vo.add("book", "a","b","c");
        vo.add("bag", "a","e","d");
        vo.add("del", "f","g","h");
        
        
        
    }
    
    public void get(){
        HyperLogLogOperations<String, String> vo = rt.opsForHyperLogLog();
        out(vo.size("book"));
        out(vo.size("bag"));
        out(vo.size("del"));
        out(vo.size("book","bag","del"));
        vo.delete("del");
        out(vo.size("book","bag","del"));
        vo.union("total", "book","bag","del");
        out(vo.size("total"));
    }
    
    public void out(String str){
        System.out.println(str);
    }
    public void out(Collection list){
        System.out.println(list);
    }
    public void out(long num){
        System.out.println(num);
    }
    public void out(boolean num){
        System.out.println(num);
    }
    public void out(DataType num){
        System.out.println(num);
    }
    public void out(Object str){
        System.out.println(str);
    }
    public void out(Set<TypedTuple<String>> set){
        for(TypedTuple<String> t : set){
            System.out.println(t.getValue()+"---"+t.getScore());
        }
    }

 

Spring RedisTemplate操作-HyperLogLog操作(7)

标签:ati   code   get   private   bag   tuple   val   int   type   

原文地址:http://www.cnblogs.com/aoeiuv/p/6760781.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!