延时任务队列的原理与实现总结

更新时间:2023-06-11 15:58:12 阅读: 评论:0

语音信箱
private int PORT = 6379;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");    public void intJedis() {
jedisPool = new JedisPool(ADDR, PORT);
}
oil paintingpublic static void main(String[] args) {
// TODO Auto-generated method stub
lingZSetTest ztTest = new ZSetTest();
ztTest.intJedis();
ztTest.addItem();
ztTest.deleteZSet();
}
public void deleteZSet() {
Jedis jedis = Resource();
jedis.del("zt_test");
}
public void addItem() {
Jedis jedis = Resource();
Calendar cal1 = Instance();
cal1.add(Calendar.SECOND, 10);
int cond10later = (int) (TimeInMillis() / 1000);
Calendar cal2 = Instance();
cal2.add(Calendar.SECOND, 20);
int cond20later = (int) (TimeInMillis() / 1000);
Calendar cal3 = Instance();
cal3.add(Calendar.SECOND, 30);
int cond30later = (int) (TimeInMillis() / 1000);
Calendar cal4 = Instance();
cal4.add(Calendar.SECOND, 40);
int cond40later = (int) (TimeInMillis() / 1000);
Calendar cal5 = Instance();
cal5.add(Calendar.SECOND, 50);
int cond50later = (int) (TimeInMillis() / 1000);
jedis.zadd("zt_test", cond50later, "e");
英语句子大全jedis.zadd("zt_test", cond10later, "a");
jedis.zadd("zt_test", cond30later, "c");
西瓜英文
jedis.zadd("zt_test", cond20later, "b");
jedis.zadd("zt_test", cond40later, "d");
redleafSystem.out.println(sdf.format(new Date()) + " add finished.");
}
public void getItem() {
Jedis jedis = Resource();
peeping
while (true) {
verifyemailtry {
谚语有哪些Set<Tuple> t = angeWithScores("zt_test", 0, 0);
String value = ((Tuple) t.toArray()[0]).getElement();
kuso是什么意思int score = (int) ((Tuple) t.toArray()[0]).getScore();
Calendar cal = Instance();
int nowSecond = (int) (TimeInMillis() / 1000);
if (nowSecond >= score) {

本文发布于:2023-06-11 15:58:12,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/141476.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图