Caching: writing and reading the cache DB.