Implement cachematrix