<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clear(self, key=None):
 """ Clear a cache entry, or the entire cache if no key is given Returns CACHE_DISABLED if the cache is disabled Returns True on successful operation :param key: optional key to limit the clear operation to (defaults to None) """

        if not self.options.enabled:
            return CACHE_DISABLED
        logger.debug('clear(key={})'.format(repr(key)))
        if key is not None and key in self._dict.keys():
            del self._dict[key]
            logger.info('cache cleared for key: ' + repr(key))
        elif not key:
            for cached_key in [k for k in self._dict.keys()]:
                del self._dict[cached_key]
            logger.info('cache cleared for ALL keys')
        return True