Mastering Cache Consistency in Distributed Systems