2

I use mapdb as following

val mycache = DBMaker.newFileDB(new File(("/data/tmp/cache.db")))
    .transactionDisable()
    .make().getHashSet("")

then when i do

mycache.put(k1, v1)
assertTrue(mycache.get(k1), v1) // all is fine

however if i restart my server i do see i have cache.db on disk however it will have an empty map when reading

so

mycache.get(k1) // is null after restart

how can i have it reread my map after restart from file?

Jas
  • 14,493
  • 27
  • 97
  • 148

1 Answers1

5

you have to close database before JVM shutdown. Easiest is to add .closeOnJVMShutdown() option

Jan Kotek
  • 1,084
  • 7
  • 4