'convenience method to attempt to get the value from the cache and
generate the value if it hasn\'t been cached yet or the entry has
otherwise been invalidated
:param key:
the key to retrieve or set
:param func:
a callable that takes no arguments and when invoked will return
the proper value'

def cache(self, key, func):

    if (key is None):
        raise ValueError('key    cannot    be    None')
    try:
        return self.get(key)
    except:
        result = func()
        self.set(key, result)
        return result
