implement cache functions for homework 2