apoc.periodic.repeat
Procedure APOC Core
apoc.periodic.repeat('name',statement, rateOrTime, config) submit a repeatedly-called background statement. Fourth parameter 'config' is optional and can contain 'params' entry for nested statement.
Signature
apoc.periodic.repeat(name :: STRING?, statement :: STRING?, rateOrTime :: OBJECT?, config = {} :: MAP?) :: (name :: STRING?, delay :: INTEGER?, rate :: INTEGER?, done :: BOOLEAN?, cancelled :: BOOLEAN?)
Input parameters
Name | Type | Default |
---|---|---|
name |
STRING? |
null |
statement |
STRING? |
null |
rate |
INTEGER? |
null |
config |
MAP? |
{} |
Output parameters
Name | Type |
---|---|
name |
STRING? |
delay |
INTEGER? |
rate |
INTEGER? |
done |
BOOLEAN? |
cancelled |
BOOLEAN? |
Usage Examples
We can create 10 Person
nodes every second by running the following query:
CALL apoc.periodic.repeat(
"create-people",
"UNWIND range(1,10) AS id CREATE (:Person {uuid: apoc.create.uuid()})",
1
);
name | delay | rate | done | cancelled |
---|---|---|---|---|
"create-people" |
0 |
1 |
FALSE |
FALSE |
We can check how many nodes have been created by running the following query:
MATCH (:Person)
RETURN count(*) AS count;
count |
---|
110 |
We can also schedule the task daily starting at a specific date or time, with the 3rd parameter as a java.time.temporal.Temporal
, for example:
CALL apoc.periodic.repeat(
"create-people",
"UNWIND range(1,10) AS id CREATE (:Person {uuid: apoc.create.uuid()})",
time("11:30")
);
If we want to cancel this job, we can use the apoc.periodic.cancel procedure.