cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Disabling Object Cache

How can I possible object cache in Neo4j-ogm?
I want this because I want to have no cache in tests, so after updating the data in the database the updated objects are not cached and when loaded from the database the actual persisted version is loaded not the version I myself gave to Neo4j. Without disabling the cache one may use a session.clear() after each update operation, which is not a clean solution.

1 ACCEPTED SOLUTION

Neo4j-OGM is built with the cache as its backbone and all the logic like knowing how deep the data was fetched and similar things are persisted also in this cache.
So simply disabling it will not only solve your problem but introduce others again.
If you really want to get rid of the cache clears, the even more expensive solution would be to derive a new session from the SessionFactory. This would on the other hand express exactly what you want to test.
Even better would be to use the Neo4j-OGM classes only for your logic you want to test and verify / assert via the pure driver that the data is there (or creating the data to test your load/fetch logic).

View solution in original post

1 REPLY 1

Neo4j-OGM is built with the cache as its backbone and all the logic like knowing how deep the data was fetched and similar things are persisted also in this cache.
So simply disabling it will not only solve your problem but introduce others again.
If you really want to get rid of the cache clears, the even more expensive solution would be to derive a new session from the SessionFactory. This would on the other hand express exactly what you want to test.
Even better would be to use the Neo4j-OGM classes only for your logic you want to test and verify / assert via the pure driver that the data is there (or creating the data to test your load/fetch logic).