refactor cachedb