views:

162

answers:

1

I'm writing a small Java-based server around Tokyo Cabinets JNI-bindings, and I am a bit confused regarding opening and closing of the db file. The server is multi-threaded, and I'm therefore wondering if it is best to open the db file upon start-up and then let the threads use get/put unsynchronized (I think that the tokyo docs state that the bindings are thread-safe) - but what happends if the server crashes without closing the db file, can it lead to data corruption? The second alternative is to create a synchronized method around get/put in which I first open the db file, get/put, and finally close it. But will the latter solution have a negative impact on performance?

What is the preferred way to let a multi-threaded application interact with tokyo cabinet?

A: 

I want to know too. The documentation promises catastrophe if the db is not closed, however a realistic server will probably get killed once in a while.

Sanketh