记事本做网站改变图片大小,建设一个大型网站需要多少钱,工信部个人备案网站可信吗,装修公司名字 有创意需求 1.⼩滴课堂官⽹需要⼀个视频学习榜单#xff0c;每天更新⼀次 2.需要⽀持⼈⼯运营替换榜单位置 企业中流程 1.定时任务计算昨天最多⼈学习的视频 2.晚上12点到1点更新到榜单上 3.预留⼀个接⼝#xff0c;⽀持⼈⼯运营 类似场景 京东#xff1a;热销⼿机榜单、电脑榜单等…需求 1.⼩滴课堂官⽹需要⼀个视频学习榜单每天更新⼀次 2.需要⽀持⼈⼯运营替换榜单位置 企业中流程 1.定时任务计算昨天最多⼈学习的视频 2.晚上12点到1点更新到榜单上 3.预留⼀个接⼝⽀持⼈⼯运营 类似场景 京东热销⼿机榜单、电脑榜单等 百度搜索热榜 疑惑为啥不是实时计算? 真正⾼并发下项⽬都是预先计算好结果然后直接返回数据且存储结构最简单 开发接⼝
import net.xdclass.xdclassredis.model.VideoDO;
import net.xdclass.xdclassredis.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
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;RestController
RequestMapping(api/v1/rank)
public class RankController {Autowiredprivate RedisTemplateString, Object redisTemplate;private static final String DAILY_RANK_KEY video:rank:daily;RequestMapping(daily_rank)public JsonData videoDailyRank(){ListVideoDO list redisTemplate.opsForList().range(DAILY_RANK_KEY,0,-1);return JsonData.buildSuccess(list);}}
测试数据
import net.xdclass.xdclassredis.model.UserDO;
import net.xdclass.xdclassredis.model.VideoDO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;import java.io.Serializable;
import java.util.UUID;
import java.util.concurrent.TimeUnit;SpringBootTest
class XdclassRedisApplicationTests {Autowiredprivate RedisTemplateString, Object redisTemplate;Testpublic void saveRank(){String DAILY_RANK_KEY video:rank:daily;VideoDO video1 new VideoDO(3,PaaS工业级微服务大课,xdclass.net,1099);VideoDO video2 new VideoDO(5,AlibabaCloud全家桶实战,xdclass.net,59);VideoDO video3 new VideoDO(53,SpringBoot2.XVue3综合实战,xdclass.net,49);VideoDO video4 new VideoDO(15,玩转23种设计模式最近实战,xdclass.net,49);VideoDO video5 new VideoDO(45,Nginx网关LVSKeepAlive,xdclass.net,89);redisTemplate.opsForList().leftPushAll(DAILY_RANK_KEY,video5,video4,video3,video2,video1);}}
人工运营操作榜单
import net.xdclass.xdclassredis.model.UserDO;
import net.xdclass.xdclassredis.model.VideoDO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;import java.io.Serializable;
import java.util.UUID;
import java.util.concurrent.TimeUnit;SpringBootTest
class XdclassRedisApplicationTests {Autowiredprivate RedisTemplateString, Object redisTemplate;Testpublic void replaceRank(){String DAILY_RANK_KEY video:rank:daily;VideoDO video new VideoDO(5432,小滴课堂面试专题第一季,xdclass.net,323);redisTemplate.opsForList().set(DAILY_RANK_KEY,1,video);}}