//1.key 2.value(经度,纬度) 3.name redisTemplate.opsForGeo().add("city",new Point(116.35,23.535),"jieyang");
System.out.println(redisTemplate.opsForGeo().position("city", "jieyang", "dongguan"));
redisTemplate.opsForGeo().distance("city","guangzhou","dongguan",KILOMETERS)
//距离300km Distance distance = new Distance(300, Metrics.KILOMETERS); //以揭阳这个地点为中心点,附件300km的城市 GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.opsForGeo().radius("city", "jieyang", distance); for( GeoResult<RedisGeoCommands.GeoLocation<Object>> radiu: radius.getContent()){ System.out.println(radiu.getContent().getName()); } //以133.11 23.037这个地点为中心点,附件300km的城市 System.out.println(redisTemplate.opsForGeo().radius("city", new Circle(new Point(113.11, 23.037), distance)));
//添加的7个数, redisTemplate.opsForHyperLogLog().add("myHkey","a","a","b","c","d","e","e"); //输出不同数的数量 System.out.println(redisTemplate.opsForHyperLogLog().size("myHkey"));
// 添加数据 1.key 2.value 3.index redisTemplate.opsForZSet().add("myzset","one",8); redisTemplate.opsForZSet().add("myzset","two",12); redisTemplate.opsForZSet().add("myzset","three",33); redisTemplate.opsForZSet().add("myzset","four",54); //按照index从小到大排序 1.key 2.从0开始 3.到-1 相对于输出全部 System.out.println(redisTemplate.opsForZSet().range("myzset", 0, -1)); //集合个数 System.out.println(redisTemplate.opsForZSet().zCard("myzset")); //index 0到20 之间的数量 System.out.println(redisTemplate.opsForZSet().count("myzset", 0, 20)); //index 0到20之间的value System.out.println(redisTemplate.opsForZSet().rangeByScore("myzset", 0, 20));
//添加数据 redisTemplate.opsForHash().put("myhash","name","cwd"); redisTemplate.opsForHash().put("myhash","age","18"); //取出数据 System.out.println(redisTemplate.opsForHash().entries("myhash")); //数量 System.out.println(redisTemplate.opsForHash().size("myhash"));
原文:https://www.cnblogs.com/miwujun/p/14342563.html