An open API service indexing awesome lists of open source software.

https://github.com/jexp/neo4j-ttl

Time To Live extension for Neo4j Nodes
https://github.com/jexp/neo4j-ttl

Last synced: about 1 year ago
JSON representation

Time To Live extension for Neo4j Nodes

Awesome Lists containing this project

README

          

== Neo4j Time To Live Extension

Adds a customizable time-to-live mechanism to Neo4j.

=== Approach

Uses indexed properties, range searches, and detach delete.

=== Installation

* Clone this repository and run `mvn install`
* Also copy `target/neo4j-ttl-1.0-SNAPSHOT.jar` to the `plugins` folder
* Modify `conf/neo4j.properties` accordingly (see the Example section)
* Restart Neo4j

=== Example

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()`

=== In Essence

[source,cypher]
----
// 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
----

=== Todo

* Support expiring of relationships