<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert(self, crc, toc):
 """ Save a new cache to file """

        if self._rw_cache:
            try:
                filename = '%s/%08X.json' % (self._rw_cache, crc)
                cache = open(filename, 'w')
                cache.write(json.dumps(toc, indent=2,
                                       default=self._encoder))
                cache.close()
                logger.info('Saved cache to [%s]', filename)
                self._cache_files += [filename]
            except Exception as exp:
                logger.warning('Could not save cache to file [%s]: %s',
                               filename, str(exp))
        else:
            logger.warning('Could not save cache, no writable directory')