统计每个用户 每日 每月 每年 搜索到关键词排行榜
代码实现排行榜数据采集端
//获取今日日期 String toDay = LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE); StringBuffer sb = new StringBuffer(); //构建用户今日排行榜明年空间 sb.append(RedisKeyConstant.KEYWORD_RANKING).append("day").append(":").append(toDay).append(":").append(openId); String rankingKey = sb.toString(); RScoredSortedSet
排行榜数据展示端
LocalDateTime now = LocalDateTime.now(); String toDay = now.format(DateTimeFormatter.BASIC_ISO_DATE); //获取当天排行榜 String rankingToday = RedisKeyConstant.KEYWORD_RANKING+"day:"+toDay; //获取今日排行榜 getRanking(rankingToday+":"+openId)) //获取当月排行榜 //获取当月的第几天 int day = now.getDayOfMonth(); String rankingToMonth = RedisKeyConstant.KEYWORD_RANKING+"month:"+toDay.substring(0,toDay.length()-2); mergeRanking(day,rankingToday.substring(0,rankingToday.length()-2),rankingToMonth,openId); getRanking(rankingToMonth+":"+openId); //获取当年排行榜 //获取当年的第几月 int month = now.getMonthValue(); int year = now.getYear(); String rankingToYear = RedisKeyConstant.KEYWORD_RANKING+"year:"+year; mergeRanking(month,rankingToMonth.substring(0,rankingToMonth.length()-2),rankingToYear,openId); getRanking(rankingToYear+":"+employee.getOpenId()) //统计并计算每日每月每年的排行榜 private void mergeRanking(int day, String needRankingKey,String destinationRankingKey,String openId) { RScoredSortedSet效果图
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)