updated cache class, also wrote test cases for cache class

Signed-off-by: Nicholas Lum <nicholaslum444@hotmail.com>