Restructed caching implementation to support caching values of any type of values