refactored cache
added function to test presence in the cache (or an environment)
(Still needs tests)