1

I have a neo4j database server sitting behind a ruby HTTP proxy that handles user authentication to a database on Heroku. I've been trying to think of an elegant way of how to handle caching of ReST responses from the neo4j server while invalidating those results when nodes and relationships change.

At the moment, my database is small and much more likely to be read than written to so keeping all GET results in a map and clearing them on POST, PUT or DELETE requests might be an option although I've not implemented it yet so no idea what the improvement is. In the longer term I would like a more fine grained solution to caching/invalidation.

Has anyone implemented anything like this or have ideas for a better solution?

Andy Till
  • 3,371
  • 2
  • 18
  • 23
  • Maybe you could have redis in front of neo4j and have all requests go through redis? Heroku does have a redis add on – Pramod Dec 31 '12 at 09:04
  • Isn't Redis another database with database-like inefficiencies (IO, querying)? – Andy Till Dec 31 '12 at 18:27
  • It is in memory, so it performs faster than a traditional database. Found any other solution yet? – Pramod Jan 12 '13 at 11:34
  • No other solutions yet. Working out which nodes and relations have been modified to expire the cache is the hardest part to do efficiently. I can't see any HTTP headers from neo4j either. – Andy Till Jan 14 '13 at 22:13
  • Does this question help? http://stackoverflow.com/questions/14026041/best-way-to-cache-restful-api-results-of-get-calls – Pramod Jan 15 '13 at 06:33
  • 1
    Do you actually have performance issues? Neo4j has its own in memory caches which are hit with this kind of requests. I'd be interested to hear more about your concerns. Some people use Redis or Memcached for more complex queries (cypher). – Michael Hunger Mar 10 '13 at 08:53
  • 1
    Hi Michael, thankyou for getting in touch. I would like my node loading to be faster over ReST. I need the nodes as well as the structure of links. Can cypher handle this? If I put results in a cache, how do I know that they will not be stale later? Or if they are invalid, how will I know so that I can remove them. If the cache get requires another network trip then I imagine I would be better off sticking with vanilla neo4j. My project is here: https://bitbucket.org/atill/estimate/downloads choose track EstiMate project to use the DB on Heroku. – Andy Till Mar 10 '13 at 13:20

0 Answers0