def METHOD_NAME(self, subject_id):
    entities = self.entities(subject_id)
    if entities:
        for entity_id in entities:
            if not self._cache.METHOD_NAME(_key(subject_id, entity_id)):
                raise CacheError("Delete failed")
    if not self._cache.METHOD_NAME(subject_id):
        raise CacheError("Delete failed")
    subjects = self._cache.get("subjects")
    if subjects and subject_id in subjects:
        subjects.remove(subject_id)
        if not self._cache.set("subjects", subjects):
            raise CacheError("Set operation failed")