首页 > 编程知识 正文

redis高可用方案,redis数据结构有哪些

时间:2023-05-06 07:56:35 阅读:18716 作者:3659

背景

用户玩游戏-实时排行榜IT视频热门实时排行榜电商商品热门实时排行榜一般排行榜读写少,可以对主控进行写操作,在多个slave上进行读操作。 如果对象记得重写HashCode和Equals方法2中的数据准备

/**积分对象* @author cv大魔王* @版本1.0 * @ date 2021/5/2115336037 */@ datapublicclassuserpointvoimplementsserializable { String phone ) { this.username=username this.phone=phone; }私有字符串用户名称; 私人串手机; @ overridepublicbooleanequals (objecto ) if ) this==o ) return true; if(o==null||getclass (!=o.getClass () ) return false; userpointvothat=(userpointvo ) o; returnobjects.equals(username,that.username ) objects.equals (phone,that.phone ); } @Override public int hashCode () returnobjects.hash ) username,phone ); }模拟数据

@ testpublicvoidtestdata ((userpointvop1=newuserpointvo )、(酷懒猪)、) 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,userpointvooperations=redis template.boundzsetops (point : rank 3360 real ); operations.add(P1,888; operations.add (p2,5456; operations.add(P3,589; operations.add (P4,17; 操作. add (P5,569; 操作. add (P6,742; 操作. add (p7,333; operations.add (P8,267; }三接口开发

/** *排名信息前五名* @ return */@ request mapping (' real _ rank1' ) public JsonData realRank ) { boundzsetoperationstionstrion returnjsondata.build success (set; } /** *返回排名信息后,返回五* @ return */@ request mapping (' real _ rank2' ) public JsonData realRank2) { boundzsetoperation returnjsondata.build success (set; } /** *查看一个用户的排名* @ return */@ request mapping (' real _ rank3' ) publicJSONdatarealrank3) stringphone, String name () ) ) ) ) ) ) 652 userpointvooperations=redis template.boundzsetops (' point : rank : real ); userpointvovo=newuserpointvo (name,phone ); longrank=operations.reverse rank (VO; returnjsondata.build success (rank ); } /** *给用户点* @ return */@ request mapping (' up rank ' ) publicJSONdatauprank ) stringphone、String name、int point userpointvovo=newuserpointvo (name,phone ); 操作. increment score (VO,point ); return JsonData.buildSuccess (; } /** *某个用户点* @ return */@ request mapping (' my point ' ) publicjsondatamypoint (stringphone,String name ) boundze userpointvovo=newuserpointvo (name,phone ); doublescore=operations.score (VO ); returnjsondata.build success (score ); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。