[BUGFIX] Caching framework: Reduce code duplication in db backend