本文共 1599 字,大约阅读时间需要 5 分钟。
@Autowired @Resource(name="redisTemplate") private RedisTemplate rt; public void flushdb(){ rt.execute(new RedisCallback () { public String doInRedis(RedisConnection connection) throws DataAccessException { connection.flushDb(); return "ok"; } }); } public void set(){ flushdb(); HyperLogLogOperations 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 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 > set){ for(TypedTuple t : set){ System.out.println(t.getValue()+"---"+t.getScore()); } }
转载于:https://my.oschina.net/haokevin/blog/1826268