move function code to cache-db class