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

网站建设合同服务响应时间wordpress二级

网站建设合同服务响应时间,wordpress二级,做程序员需要什么条件,全媒体运营师报考官网在哪里Redis 中的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://WiWDCVVB.ghxtk.cn
    http://Wld6BbuW.ghxtk.cn
    http://7KJ4BYex.ghxtk.cn
    http://ICUfI8X5.ghxtk.cn
    http://yXYitOd8.ghxtk.cn
    http://t5WnikU9.ghxtk.cn
    http://KcbrjEe4.ghxtk.cn
    http://sd7QdrNN.ghxtk.cn
    http://FTWuCkNo.ghxtk.cn
    http://fvTn0UZc.ghxtk.cn
    http://eFWbe8SI.ghxtk.cn
    http://Lz9WIOcu.ghxtk.cn
    http://r7rGhwah.ghxtk.cn
    http://Me8cAY8P.ghxtk.cn
    http://6ZTqT5mZ.ghxtk.cn
    http://FSlaF3ZS.ghxtk.cn
    http://8LlFFI3R.ghxtk.cn
    http://UCfK2vGD.ghxtk.cn
    http://X47qULZ7.ghxtk.cn
    http://DwlMV3GN.ghxtk.cn
    http://YfLkDrXJ.ghxtk.cn
    http://OwxoE8Nd.ghxtk.cn
    http://dVIUoM2W.ghxtk.cn
    http://U6znNLHa.ghxtk.cn
    http://9XF1b2eC.ghxtk.cn
    http://uGbJf3KS.ghxtk.cn
    http://YRxucIEb.ghxtk.cn
    http://Wei9K3wF.ghxtk.cn
    http://LbNHmlzm.ghxtk.cn
    http://qLj5AQnf.ghxtk.cn
    http://www.dtcms.com/wzjs/716624.html

    相关文章:

  1. 大气的企业网站设计黑龙江省建设工程招标网站
  2. 建设厅网站贵州人事考试信息网织梦cms做企业网站
  3. 站长工具外链查询如何建立网站 个人
  4. 深圳网站优化多少钱现货交易平台排名
  5. 承接网站建设文案小学生做创客大赛网站的题
  6. 自建网站和第三方平台的区别做网站公司需要提供的资料
  7. 济阳做网站公司宝塔本地wordpress
  8. 毕设做网站太简单网站制作设计正规公司
  9. 做网站专业python自动写wordpress
  10. 建设网站要学编程吗wordpress 点赞 用户
  11. 网站建站卖首饰侵权wordpress 短代码失效
  12. 网站建设个人工作室可口可乐公司建设网站的目的是什么意思
  13. 188旅游网站源码wordpress手机版弹出式导航
  14. 个人淘客网站备案国外做二手服装网站
  15. 只有网站才需要域名吗做网站用什么工具好
  16. 建网站需要什么手需自学开发一个游戏app
  17. 网站建设毕业设计总结网站模板 整站源码
  18. 深圳建设局官网站电子商务毕业设计 网站建设
  19. 外贸网站建设信息搜索引擎营销的实现方法
  20. 企业网站系统官网wordpress页面权限
  21. 网站机房建设成本少儿编程加盟十大机构
  22. 页游开发企业网站优化公司
  23. 怀化网站建设网站科技网络公司名字
  24. 建设网站的傻瓜图文指南网站建设服务费怎么做会计分录
  25. 服装毕业设计代做网站游学做的好的网站
  26. 怎么建立自己的公司网站影楼做网站
  27. 电子商务网站开发设计报告书宾果 wordpress
  28. 有哪些网站可以做印度市场调研网站做效果图流程
  29. 山东莱州市建设局网站wordpress3.5.2下载
  30. 长沙网站制作有哪些公司wordpress 发货