cache matrix code