任何人都可以解释一下 lockAtLeastFor = "PT1M45S", lockAtMostFor = "PT2M" 中提到的时间,这里的 PT 是什么
Can anyone please explain about the timing mentioned in lockAtLeastFor = "PT1M45S", lockAtMostFor = "PT2M" what is PT here
任何人都可以解释一下 lockAtLeastFor 和 lockAtMostFor 中定义的时间。什么是PT1M45S,它还能接受哪些参数。
@Scheduled(cron = "0 0/2 * * * *")
@SchedulerLock(name = "TaskScheduler_scheduledTask", lockAtLeastFor = "PT1M45S", lockAtMostFor = "PT2M")
public void performJob()
{
System.out.println("executed");
}
这是ISO 8601 format for duration。
您似乎正在使用 ShedLock。
根据文档,它可以接受以毫秒为单位的持续时间。
/**
* The lock will be held at least for X millis. Can be used if you really need to execute the task
* at most once in given period of time. If the duration of the task is shorter than clock difference between nodes, the task can
* be theoretically executed more than once (one node after another). By setting this parameter, you can make sure that the
* lock will be kept at least for given period of time.
*/
long lockAtLeastFor() 默认 -1;
文档指出:
Can be either time with suffix like 10s or ISO8601 duration as described in {@link java.time.Duration#parse(CharSequence)}, for example PT30S.
也就是ISO-8601 duration format。 P
代表周期并且(可选)后跟以年 (Y
)、月 (M
)、周 (W
) 和天 (D
). T
代表时间,后面跟着一个或多个小时 (H
)、分钟 (M
) 和(小数)秒 (S
)。
另请参阅 Duration.parse
的 javadoc。 Java 支持的持续时间格式不支持 ISO-8601 中规定的 Y
、M
和 W
,而是使用像 PnDTnHnMn.nS
这样的简化格式.
它在 ShedLock 文档中指定
Duration specification
- duration+unit - 1s, 5ms, 5m, 1d (Since 4.0.0)
- duration in ms - 100 (only Spring integration)
- ISO-8601 - PT15M (see Duration.parse() documentation)
https://github.com/lukas-krecan/ShedLock#duration-specification
任何人都可以解释一下 lockAtLeastFor 和 lockAtMostFor 中定义的时间。什么是PT1M45S,它还能接受哪些参数。
@Scheduled(cron = "0 0/2 * * * *")
@SchedulerLock(name = "TaskScheduler_scheduledTask", lockAtLeastFor = "PT1M45S", lockAtMostFor = "PT2M")
public void performJob()
{
System.out.println("executed");
}
这是ISO 8601 format for duration。
您似乎正在使用 ShedLock。 根据文档,它可以接受以毫秒为单位的持续时间。
/** * The lock will be held at least for X millis. Can be used if you really need to execute the task * at most once in given period of time. If the duration of the task is shorter than clock difference between nodes, the task can * be theoretically executed more than once (one node after another). By setting this parameter, you can make sure that the * lock will be kept at least for given period of time. */
long lockAtLeastFor() 默认 -1;
文档指出:
Can be either time with suffix like 10s or ISO8601 duration as described in {@link java.time.Duration#parse(CharSequence)}, for example PT30S.
也就是ISO-8601 duration format。 P
代表周期并且(可选)后跟以年 (Y
)、月 (M
)、周 (W
) 和天 (D
). T
代表时间,后面跟着一个或多个小时 (H
)、分钟 (M
) 和(小数)秒 (S
)。
另请参阅 Duration.parse
的 javadoc。 Java 支持的持续时间格式不支持 ISO-8601 中规定的 Y
、M
和 W
,而是使用像 PnDTnHnMn.nS
这样的简化格式.
它在 ShedLock 文档中指定
Duration specification
- duration+unit - 1s, 5ms, 5m, 1d (Since 4.0.0)
- duration in ms - 100 (only Spring integration)
- ISO-8601 - PT15M (see Duration.parse() documentation)
https://github.com/lukas-krecan/ShedLock#duration-specification