Completed cache matrix implementation.