def METHOD_NAME(self, term, value, inventory_dir):
    try:
        with open(self._secrets_cache_filename(term, inventory_dir=inventory_dir), 'wb') as f:
            f.write(Fernet(self._encryption_key()).encrypt(pickle.dumps(value)))
    except Exception as e:
        logging.warn('There was an error caching the secret {}'.format(e))
        raise