Fix race with opening db connection
Read cache size from config