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
- Host: GitHub
- URL: https://github.com/jexp/neo4j-ttl
- Owner: jexp
- Created: 2016-02-12T21:21:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-16T11:03:39.000Z (over 10 years ago)
- Last Synced: 2025-03-23T11:11:23.249Z (over 1 year ago)
- Language: Java
- Size: 12.7 KB
- Stars: 3
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: readme.adoc
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