I am relatively new to Neo4J. This is my first time building a plugin (on java).
I am trying to get my plugin to preprocess data in the graph and store it as cache to use later in queries using procedures defined in the same plugin.
I am getting the impression that I can extend org.neo4j.kernel.lifecycle.LifecycleAdapter and override the start() method.
But I am not sure if:
LifecycleAdapter is for the procedure lifecycle or the database lifecycle
If it is for the database lifecycle, how can I get it to run. Currently I have tried and start() doesn't run on db startup.
Can Neo4J store plugin cache?
eg. private static final Map<String, List> cache = new HashMap<>();
Sorry I can't help with the db events listeners, as I have not used any.
I don't see a reason you can create a class and have is support your caching. I do have two points to consider:
I would not use a hashMap as it does not have any expiration capabilities. Look at Google's Guava cash or Caffine cache. I have used both, and have guava in a heavy production environment
You have to be careful in cluster environment, as each jvm would have their own independent cache. If you want to write to these caches during the application's life, then you are going to have syncronization issues. You will need a distributed cache, such as Ehcache. If you are just hydrating at startup and you can ensure each jam will calculate the same cached values, then you can use this approach.