apoc.periodic.countdown

This procedure is not intended to be used in a cluster environment, and may act unpredictably. It continues to execute against the same database that it was initiated on, meaning that in a cluster environment, it only executes on the leader. If there is a leader switch then the procedure may error and stop running.

Jobs share a DBMS-wide registry keyed solely by name without ownership verification. Scheduling a job with an existing name silently cancels and replaces the active job with the caller’s query. To restrict access, configure DENY EXECUTE PROCEDURE apoc.periodic.countdown ON DBMS TO `PUBLIC`. For more information, see the Operations Manual → Procedure and user-defined function privileges.

Details

Syntax

apoc.periodic.countdown(name, statement, delay) :: (name, delay, rate, done, cancelled)

Description

Runs a repeatedly called background statement until it returns 0.

Input arguments

Name

Type

Description

name

STRING

The name of the job.

statement

STRING

The Cypher statement to run, returning a count on each run indicating the remaining iterations.

delay

INTEGER

The delay in seconds to wait between each job execution.

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

The examples in this section are based on the following sample graph:

CREATE (:Counter {value: 10000});
The following decrements the value once a second until it gets to 0:
CALL apoc.periodic.countdown(
  "decrement",
  "MATCH (counter:Counter)
   SET counter.value = counter.value - 1
   RETURN counter.value as count",
  1);