mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
添加cache-loader,debug模式下不再使用template缓存,修复一些 bug
This commit is contained in:
1 parent
dd7914e1fb
commit
11368bc831
21 files changed
+248
-266
No files matched your search
+6
-7
@@ -28,20 +28,19 @@ export function del(_id: ObjectID) {
|
||||
export async function getFirst(query: any) {
|
||||
const q = { ...query };
|
||||
q.executeAfter = q.executeAfter || { $lt: new Date().getTime() };
|
||||
const res = await coll.find(q).sort('_id', 1).limit(1).toArray();
|
||||
if (res.length) {
|
||||
await coll.deleteOne({ _id: res[0]._id });
|
||||
if (res[0].interval) {
|
||||
const res = await coll.findOneAndDelete(q);
|
||||
if (res.value) {
|
||||
if (res.value.interval) {
|
||||
await coll.insertOne({
|
||||
...res[0], executeAfter: moment().add(...res[0].interval).toDate(),
|
||||
...res.value, executeAfter: moment().add(...res.value.interval).toDate(),
|
||||
});
|
||||
}
|
||||
return res[0];
|
||||
return res.value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function consume(query, cb: Function) {
|
||||
export async function consume(query: any, cb: Function) {
|
||||
let isRunning = false;
|
||||
const interval = setInterval(async () => {
|
||||
if (isRunning) return;
|
||||
|
||||
Reference in new issue
Block a user