Added cache opening and closing. Written database read/write from/to
file.