Update cache.php

general improvements, slimmed down cache->get() and re-factored the 'check' code in cache->get()