当前位置: 首页 > wzjs >正文

少儿编程十大骗局上海哪家seo公司好

少儿编程十大骗局,上海哪家seo公司好,怎么做网页的超链接,无锡做网站f7wlRedis 中的SortedSet结构非常适合用于实现实时榜单的场景,它根据成员的分数自动进行排序,支持高效的添加、更新和查询操作。 SortedSet实时榜单的一些典型应用场景: 游戏中的玩家排行榜:在多人在线游戏中,使用 Sorte…

Redis 中的SortedSet结构非常适合用于实现实时榜单的场景,它根据成员的分数自动进行排序,支持高效的添加、更新和查询操作。

SortedSet实时榜单的一些典型应用场景:

游戏中的玩家排行榜:在多人在线游戏中,使用 SortedSet来维护玩家的得分排行榜,可以按照玩家的得分来排序,方便展示顶级玩家或者好友间的排名情况。

电商热销榜:像淘宝、京东等电商平台的热销商品榜单(例如热销手机、电脑等)。通过 SortedSet可以轻松维护基于销量或其他指标的商品排名,并能快速获取最新的排名信息。

体育赛事积分榜:在体育赛事的应用场景中,利用 SortedSet维护各队伍或运动员的比赛积分、胜率等统计数据的排行榜,以便实时更新和展示最新的排名情况。

下面我们来实战一下用户积分实时榜单!今天实战的内容有查看全部榜单(从大到小);查看前三名的榜单(从大到小);查看某个用户的排名;给某个用户加积分,之后返回所有榜单;查看个人的积分。

对象准备(记得重写HashCode与Equals方法):

public class UserPointVO {private String username;private String phone;public UserPointVO(String username, String phone) {this.username = username;this.phone = phone;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;UserPointVO that = (UserPointVO) o;return phone.equals(that.phone);}@Overridepublic int hashCode() {return Objects.hash(phone);}
}

数据准备:

@Testvoid testData() {UserPointVO p1 = new UserPointVO("老A","324");UserPointVO p2 = new UserPointVO("老B","242");UserPointVO p3 = new UserPointVO("老C","542345");UserPointVO p4 = new UserPointVO("老D","235");UserPointVO p5 = new UserPointVO("老E","1245");UserPointVO p6 = new UserPointVO("老F","2356432");UserPointVO p7 = new UserPointVO("老G","532332");UserPointVO p8 = new UserPointVO("老H","13113");BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");operations.add(p1,324);operations.add(p2,542);operations.add(p3,52);operations.add(p4,434);operations.add(p5,1123);operations.add(p6,64);operations.add(p7,765);operations.add(p8,8);}

redis中的数据:

 

我们首先开发返回全部榜单,从大到小的接口:

/***返回全部榜单,从大到小* @return*/@RequestMapping("real_rank1")public JsonData realRank1(){BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");Set<UserPointVO> set = operations.reverseRange(0, -1);return JsonData.buildSuccess(set);}

打印结果为:

 

 接着开发返回前三名榜单的接口:

 /***返回指定大小榜单,从大到小,这里是返回前三名* @return*/@RequestMapping("real_rank2")public JsonData realRank2(){BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");Set<UserPointVO> set = operations.reverseRange(0, 2);return JsonData.buildSuccess(set);}

打印结果为:

 

查看某个用户的排名:

/*** 查看某个用户的排名* @param name* @param phone* @return*/@RequestMapping("find_myrank")public JsonData realMyRank(String name,String phone){BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");UserPointVO userPointVO = new UserPointVO(name,phone);long rank = operations.reverseRank(userPointVO);return JsonData.buildSuccess(++rank);}

这里我们查看老H的排名,打印结果为:

 

给某个用户加积分:

/*** 给某个用户加积分,之后返回所有榜单* @param name* @param phone* @param point* @return*/@RequestMapping("uprank")public JsonData upRank(String name,String phone,int point){BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");UserPointVO userPointVO = new UserPointVO(name,phone);operations.incrementScore(userPointVO,point);Set<UserPointVO> set = operations.reverseRange(0, -1);return JsonData.buildSuccess(set);}

这里我们给老H加1000的积分,打印结果为:

 

查看个人的积分:

/*** 查看个人的积分* @param name* @param phone* @return*/@RequestMapping("mypoint")public JsonData mypoint(String name,String phone){BoundZSetOperations<String, UserPointVO> operations = redisTemplate.boundZSetOps("point:rank:real");UserPointVO userPointVO = new UserPointVO(name,phone);double score = operations.score(userPointVO);return JsonData.buildSuccess(score);}

这里我们还是查看老H的积分:

 

 

 

 

 

 

 

 

    http://www.dtcms.com/wzjs/247958.html

    相关文章:

  1. 鄄城网站开发网页加速器
  2. 南山做网站联系电话网络销售平台上市公司有哪些
  3. dede茶叶网站模板武汉网络优化知名乐云seo
  4. 技术支持 深圳网站建设贝尔利河南品牌网站建设
  5. 网站备案名可以更改吗湖南seo服务
  6. 怎样创建公司网站国内最好用免费建站系统
  7. wordpress分类静态天津百度seo推广
  8. 怎么做国际货运代理外贸网站百度集团总部在哪里
  9. 怎么做网店网站兰州百度推广的公司
  10. 搭建视频服务器百度关键词seo
  11. 佛山响应式网站开发单页面seo搜索引擎优化
  12. 乐清网站推广温岭网络推广
  13. 网上做衣服的网站有哪些东莞关键词优化实力乐云seo
  14. 学校网站三合一建设方案java培训机构十强
  15. 做网站需要多少钱 做电商平台运营
  16. 上海自助建站平台百度域名购买
  17. 四川酒店网站建设线上推广平台报价
  18. 厦门外贸网站建设哪家公司大今日头条最新
  19. 环球设计官网长沙官网seo分析
  20. 如何寻找做企业网站的肇庆疫情最新情况
  21. 一般通过政府部门泉州百度seo
  22. wordpress电商建站长尾关键词举例
  23. 北京企业网站建设费用seo网站排名
  24. 绵阳 网站 建设餐饮营销手段13种手段
  25. 河源网站推广网站关键词提升
  26. 263net企业邮箱曲靖seo
  27. 网站建设服务商排名如何查询百度收录情况
  28. 公司网站备案要多久如何在百度上发布自己的广告
  29. 郑州网站建设公司排行今日疫情实时数据
  30. 做网站编辑的感受网站开发的基本流程