How can I share an object between threads without having to reload it?

8 views
Skip to first unread message

Matias Burak

unread,
Sep 4, 2016, 8:40:30 PM9/4/16
to Neo4j
We have an application where we need to do some high-performance operations so we do them in batches in multiple threads.

There are some objects that we would like to cache in a LoadingCache and use them in all the threads without having to get them again and again from the database.
The problem with this is that neo4j driver is not allowing to share an object between sessions, even when that object is not going to be changed at that point. The error we are getting is:

  • Exception on sync: org.neo4j.driver.v1.exceptions.ClientException: You are using a session from multiple locations at the same time, which is not supported. If you want to use multiple threads, you should ensure that each session is used by only one thread at a time. One way to do that is to give each thread its own dedicated session.

Is there a way we can accomplish this without having to reload the object from db again and again in each thread (so they use a different session)?
 
Thanks,
Matias.
Reply all
Reply to author
Forward
0 new messages