update cache matrix