Code matrix cache functions