apoc.periodic.repeat

Details

Syntax

apoc.periodic.repeat(name, statement, rate [, config ]) :: (name, delay, rate, done, cancelled)

Description

Runs a repeatedly called background job. To stop this procedure, use apoc.periodic.cancel.

Input arguments

Name

Type

Description

name

STRING

The name of the job.

statement

STRING

The Cypher statement to run.

rate

INTEGER

The delay in seconds to wait between each job execution.

config

MAP

{ params = {} :: MAP } The default is: {}.

Return arguments

Name

Type

Description

name

STRING

The name of the job.

delay

INTEGER

The delay on the job.

rate

INTEGER

The rate of the job.

done

BOOLEAN

If the job has completed.

cancelled

BOOLEAN

If the job has been cancelled.

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
);
Results
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;
Results
count

110

If we want to cancel this job, we can use the apoc.periodic.cancel procedure.