restructured cache functions