Adds a customizable time-to-live mechanism to Neo4j.
-
Clone this repository and run
mvn install
-
Also copy
target/neo4j-ttl-1.0-SNAPSHOT.jar
to theplugins
folder -
Modify
conf/neo4j.properties
accordingly (see the Example section) -
Restart Neo4j
If you configure in conf/neo4j.properties
:
ttl.label=Timed ttl.property=ttl ttl.schedule=60s
With that in place, Neo4j will now track changes to nodes labeled
Timed
and expires them after their ttl
property is smaller than the current timestamp()
// create index for range searches
CREATE INDEX ON :Timed(ttl);
// create time-bound node
CREATE (n:Token:Timed {uid:"38948-3434-33", ttl:timestamp() + 180*1000});
// schedule to run regularly
MATCH (n:Timed) WHERE n.ttl <= timestamp() WITH n LIMIT 10000 DETACH DELETE n RETURN count(*) as c