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

jsp电影网站开发教程站酷网站

jsp电影网站开发教程,站酷网站,专门做别墅的网站,广告平台代理案例实战之SortedSet⽤户积分实时榜单最佳实践 背景 ⽤户玩游戏-积分实时榜单 IT视频热销实时榜单 电商商品热销实时榜单 ⼀般的排⾏榜读多写少#xff0c;可以对 master 进⾏写⼊操作#xff0c;然后多个 slave 进⾏读取操作。如果是对象记得重写HashCode与Equals⽅法 User…案例实战之SortedSet⽤户积分实时榜单最佳实践 背景 ⽤户玩游戏-积分实时榜单 IT视频热销实时榜单 电商商品热销实时榜单 ⼀般的排⾏榜读多写少可以对 master 进⾏写⼊操作然后多个 slave 进⾏读取操作。如果是对象记得重写HashCode与Equals⽅法 UserPointVO package net.xdclass.xdclassredis.vo;import java.util.Objects;public class UserPointVO {public UserPointVO(String username, String phone) {this.username username;this.phone phone;}private String username;private String 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 Objects.equals(phone, that.phone);}Overridepublic int hashCode() {return Objects.hash(phone);} } 加入测试数据 SpringBootTest class XdclassRedisApplicationTests {Autowiredprivate RedisTemplate redisTemplate;Testvoid testData() {UserPointVO p1 new UserPointVO(老王,13113);UserPointVO p2 new UserPointVO(老A,324);UserPointVO p3 new UserPointVO(老B,242);UserPointVO p4 new UserPointVO(老C,542345);UserPointVO p5 new UserPointVO(老D,235);UserPointVO p6 new UserPointVO(老E,1245);UserPointVO p7 new UserPointVO(老F,2356432);UserPointVO p8 new UserPointVO(老G,532332);BoundZSetOperationsString, 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);} } 接⼝开发 返回榜单-从⼤到⼩排序 查看这个⼈的排名,从⼤到⼩0就是第⼀ 给某个⽤户加积分 查看某个⽤户的积分 import net.xdclass.xdclassredis.model.VideoDO; import net.xdclass.xdclassredis.util.JsonData; import net.xdclass.xdclassredis.vo.UserPointVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.BoundZSetOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.List; import java.util.Set;RestController RequestMapping(api/v1/rank) public class RankController {Autowiredprivate RedisTemplate redisTemplate;private static final String DAILY_RANK_KEY video:rank:daily;/*** 返回全部榜单从大到小* return*/RequestMapping(real_rank1)public JsonData realRank1() {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);SetUserPointVO set operations.reverseRange(0, -1);return JsonData.buildSuccess(set);}/*** 返回全部榜单从小到大* return*/RequestMapping(real_rank2)public JsonData realRank2() {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);SetUserPointVO set operations.range(0, -1);return JsonData.buildSuccess(set);}/*** 返回全部榜单从大到小,指定长度* return*/RequestMapping(real_rank3)public JsonData realRank3() {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);SetUserPointVO set operations.reverseRange(0, 3);return JsonData.buildSuccess(set);}/*** 查看某个用户的排名* param phone* param name* return*/RequestMapping(find_myrank)public JsonData realMyRank(String phone,String name) {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);UserPointVO userPointVO new UserPointVO(name,phone);long rank operations.reverseRank(userPointVO);return JsonData.buildSuccess(rank);}/*** 加积分* param phone* param name* return*/RequestMapping(uprank)public JsonData uprank(String phone,String name,int point) {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);UserPointVO userPointVO new UserPointVO(name,phone);operations.incrementScore(userPointVO,point);SetUserPointVO set operations.range(0, -1);return JsonData.buildSuccess(set);}/*** 查看个人的积分* param phone* param name* return*/RequestMapping(mypoint)public JsonData mypoint(String phone,String name) {BoundZSetOperationsString, UserPointVO operations redisTemplate.boundZSetOps(point:rank:real);UserPointVO userPointVO new UserPointVO(name,phone);double score operations.score(userPointVO);return JsonData.buildSuccess(score);}}
http://wiki.neutronadmin.com/news/29597/

相关文章:

  • 柳州网站制作公司seo关键词优化推广价格
  • 安徽企业网站制作网站建设与管理的流程方案
  • 悬赏做logo的网站义乌外贸
  • 网站是不是用cms做的建筑工程网络设计
  • 大型门户网站有哪些国内装修公司排名前十强
  • 孝感市建设局网站徐州社交网站
  • 网站建设的公司有发展吗网络推广合作平台
  • 南阳做网站哪个好uc导航
  • 云服务器建立多个网站企业营销策划实训报告
  • 韩国教做发饰的网站广东东莞招工信息最新招聘
  • 专业网站推广的公司哪家好推销产品怎样才能打动客户
  • 网站建设商标注册多少类目北京网页设计机构
  • 衡水龙腾网站建设做网站字体规范
  • dz如何做门户网站南京谁做免费网站
  • 做外贸需要关注的网站有什么问题推广普通话周
  • 网站搭建哪里找最好做网站卖大闸蟹
  • 深圳装饰网站建设vs2010网站开发教程
  • 重庆网站建设mswzjs货源网站 源码
  • 百度网站建设电话销售话术厦门网红桥
  • 完成网站建设成本正能量应该懂我的意思
  • 北京 高端网站设计外链发布论坛
  • 做外贸没网站可以吗wordpress 过滤图片
  • 深圳 网站设计师 招聘自己的网站如何做分销
  • 网站的后台怎么做调查问卷湖南网站建设公司 地址磐石网络
  • 贸易公司注册多少钱宁波企业seo推广
  • ps制作网站背景科技企业网站设计制作
  • 重庆网站建设的目的wordpress 首页调用页面
  • 旅游网站建设网站推广vs做网站案例
  • 微信公众平台网站建设广西南宁网站建设公司
  • 水果网站建设windows下wordpress