小编Cri*_*rta的帖子

跨TimeZone的Java Quartz-Scheduler

我的服务器在欧洲/罗马时区运行 - 这个是服务器上的默认tz,我需要根据用户的时区安排工作,因此,如果居住在太平洋/檀香山时区的用户安排一个CronTrigger,每个人都会触发我发现这个解决方案的一天是晚上22点为他的地球区域:

CronTrigger trigger = newTrigger()
  .withIdentity("name", "group")
  .withSchedule(
    cronSchedule("0 0 22 ? * *").inTimeZone(TimeZone.getTimeZone("Pacific/Honolulu"))
  )
  .startNow()
  .build();
Run Code Online (Sandbox Code Playgroud)

在我的服务器上,这个工作从第二天"我的"上午09:00开始.

除了保持更新时区(即时区更新工具)之外,还有一些特殊问题需要考虑吗?

如果我想为前一个作业定义.startAt()和.endAt(),这种日期是否正常?使用此程序可以安全地节省夏令时吗?

Calendar calTZStarts = new GregorianCalendar(TimeZone.getTimeZone("Pacific/Honolulu"));
calTZStarts.set(2013, Calendar.JANUARY, 10);

Calendar calTZEnds = new GregorianCalendar(TimeZone.getTimeZone("Pacific/Honolulu"));
calTZEnds.set(2013, Calendar.JANUARY, 30);

Calendar calStarts = Calendar.getInstance();
calStarts.set(Calendar.YEAR, calTZStarts.get(Calendar.YEAR));
calStarts.set(Calendar.MONTH, calTZStarts.get(Calendar.MONTH));
calStarts.set(Calendar.DAY_OF_MONTH, calTZStarts.get(Calendar.DAY_OF_MONTH));
calStarts.set(Calendar.HOUR_OF_DAY, calTZStarts.get(Calendar.HOUR_OF_DAY));
calStarts.set(Calendar.MINUTE, calTZStarts.get(Calendar.MINUTE));
calStarts.set(Calendar.SECOND, calTZStarts.get(Calendar.SECOND));
calStarts.set(Calendar.MILLISECOND, calTZStarts.get(Calendar.MILLISECOND));

Calendar calEnds = Calendar.getInstance();
calEnds.set(Calendar.YEAR, calTZEnds.get(Calendar.YEAR));
calEnds.set(Calendar.MONTH, calTZEnds.get(Calendar.MONTH));
calEnds.set(Calendar.DAY_OF_MONTH, calTZEnds.get(Calendar.DAY_OF_MONTH));
calEnds.set(Calendar.HOUR_OF_DAY, calTZEnds.get(Calendar.HOUR_OF_DAY));
calEnds.set(Calendar.MINUTE, calTZEnds.get(Calendar.MINUTE));
calEnds.set(Calendar.SECOND, calTZEnds.get(Calendar.SECOND));
calEnds.set(Calendar.MILLISECOND, calTZEnds.get(Calendar.MILLISECOND));

CronTrigger …
Run Code Online (Sandbox Code Playgroud)

java timezone scheduled-tasks quartz-scheduler

9
推荐指数
1
解决办法
2万
查看次数

MySQL到Redis - 导入和模型

我正在考虑使用Redis来缓存一些用户数据快照,以加快对该数据的访问(其中一个原因是因为我的MySQL表遭受锁争用)而且我正在寻找一步导入这样一个表的最佳方法(可能包含几条记录到数百万条记录):

mysql> select * from mytable where snapshot = 1133;
+------+--------------------------+----------------+-------------------+-----------+-----------+
| id   | email                    | name           | surname           | operation | snapshot  |
+------+--------------------------+----------------+-------------------+-----------+-----------+
| 2989 | example-2989@example.com | fake-name-2989 | fake-surname-2989 |         2 |      1133 |
| 2990 | example-2990@example.com | fake-name-2990 | fake-surname-2990 |        10 |      1133 |
| 2992 | example-2992@example.com | fake-name-2992 | fake-surname-2992 |         5 |      1133 |
| 2993 | example-2993@example.com | fake-name-2993 | fake-surname-2993 |         5 |      1133 |
| …
Run Code Online (Sandbox Code Playgroud)

mysql nosql redis key-value-store

6
推荐指数
1
解决办法
6797
查看次数