Cache related published objects in `pre_clear` so they can be restored in
    `post_clear`.
423920
def handle_publishable_m2m_changed(
        sender, instance, action, reverse, model, pk_set, **kwargs):
    
    # Do nothing if the target model is not publishable.
    if not issubclass(model, PublishingModel):
        return
    # Get the right `ManyRelatedManager`. Iterate M2Ms and compare `sender`
    # (the through model), in case there are multiple M2Ms to the same model.
    if reverse:
        for rel_obj in instance._meta.get_all_related_many_to_many_objects():
            if rel_obj.field.rel.through == sender:
                m2m = getattr(instance, rel_obj.get_accessor_name())
                break
    else:
        for field in instance._meta.many_to_many:
            if field.rel.through == sender:
                m2m = getattr(instance, field.attname)
                break
    # Cache published PKs on the instance.
    if action == 'pre_clear':
        instance._published_m2m_cache = set(
            m2m.filter(publishing_is_draft=False).values_list('pk', flat=True))
    # Add published PKs from the cache.
    if action == 'post_clear':
        m2m.add(*instance._published_m2m_cache)
        del instance._published_m2m_cache
1258056
public function clear()
    {
        if (null !== $this->aSkillRelatedByPartId) {
            $this->aSkillRelatedByPartId->removePart($this);
        }
        if (null !== $this->aSkillRelatedByCompositeId) {
            $this->aSkillRelatedByCompositeId->removeComposite($this);
        }
        $this->part_id = null;
        $this->composite_id = null;
        $this->alreadyInSave = false;
        $this->clearAllReferences();
        $this->resetModified();
        $this->setNew(true);
        $this->setDeleted(false);
    }
273637
def relation_clear(r_id=None):
    '''  '''
    settings = relation_get(rid=r_id,
                            unit=local_unit())
    for setting in settings:
        if setting not in ['public-address', 'private-address']:
            settings[setting] = None
    relation_set(relation_id=r_id,
                 **settings)
260165
def clearCache(self):
        ''
        for attr in self.cacheItems:
            if hasattr(self, attr):
                delattr(self, attr)
919841
public void cleanUpNullReferences() {
        final Iterator<Map.Entry<Object, Object>> iterator = cache.entrySet().iterator();
        while (iterator.hasNext()) {
            final Map.Entry<Object, Object> entry = iterator.next();
            Object entryVal = entry.getValue();
            if (entryVal != null && ((SoftReference) entryVal).get() == null) cache.remove(entry.getKey(), entryVal);
        }
    }
949564
private void cleanup() {
		CacheEntry oldest = null;
		_count = 0;

		// Cleanup obsolete entries and find the oldest
		for (Map.Entry<String, CacheEntry> e : _cache.entrySet()) {
			String key = e.getKey();
			CacheEntry entry = e.getValue();
			// Remove obsolete entry
			if (entry.isExpired()) {
				_cache.remove(key);
			}
			// Count the remaining entry
			else {
				_count++;
				if (oldest == null || oldest.getExpiration() > entry.getExpiration())
					oldest = entry;
			}
		}

		// Remove the oldest if cache size exceeded maximum
		if (_count > _maxSize && oldest != null) {
			_cache.remove(oldest.getKey());
			_count--;
		}
	}
657121
def _prune_invalidated_entries(self):
        ""
        self.access_log_lock.acquire()
        self.access_log = deque(e for e in self.access_log if e.is_valid)
        self.access_log_lock.release()
814342
def clear_caches(self):
        """"""
        self.get_repository.cache_clear()
        self._get_repository.cache_clear()
        self.pool.clear_caches()
940432
def clear_published(self):
        
        # Implemented from template for osid.resource.ResourceForm.clear_group_template
        if (self.get_published_metadata().is_read_only() or
                self.get_published_metadata().is_required()):
            raise errors.NoAccess()
        self._my_map['published'] = self._published_default
946399
def preprocess_search_hit(pid, record_hit, links_factory=None, **kwargs):
        """"""
        links_factory = links_factory or (lambda x, **k: dict())
        record = dict(
            pid=pid,
            metadata=record_hit['_source'],
            links=links_factory(pid, record_hit=record_hit, **kwargs),
            revision=record_hit['_version'],
            created=None,
            updated=None,
        )
        # Move created/updated attrs from source to object.
        for key in ['_created', '_updated']:
            if key in record['metadata']:
                record[key[1:]] = record['metadata'][key]
                del record['metadata'][key]
        return record
1010019
def clear_caches():  # suppress(unused-function)
    """"""
    for _, reader in _spellchecker_cache.values():
        reader.close()

    _spellchecker_cache.clear()
    _valid_words_cache.clear()
    _user_dictionary_cache.clear()
455720
def __clear_references(self, request, remove_request=True):
        """"""
        # remove request itself
        if remove_request:
            with self.__requests:
                self.__requests.pop(request.id_)
        # remove request type specific references
        if not request.success:
            with self.__pending_subs:
                self.__pending_subs.pop(request.id_, None)
            with self.__pending_controls:
                self.__pending_controls.pop(request.id_, None)
1242299
def clear_published_date(self):
        
        # Implemented from template for osid.assessment.AssessmentOfferedForm.clear_start_time_template
        if (self.get_published_date_metadata().is_read_only() or
                self.get_published_date_metadata().is_required()):
            raise errors.NoAccess()
        self._my_map['publishedDate'] = self._published_date_default
760776
def collect_cached_objects(self, versioned_target):
    
    return ObjectFiles(versioned_target.results_dir, os.listdir(versioned_target.results_dir))
938396
private function catalogRefresh()
    {
        Relation::r()->preload();
        Attribute::r()->preload();
        Type::r()->preload();
        Index::r()->preload();
    }
323357
def _update(self, request, *args, **kwargs):
        """"""
        partial = kwargs.pop('partial', False)
        # NOTE: The line below was changed.
        instance = self.get_object_with_lock()
        serializer = self.get_serializer(instance, data=request.data, partial=partial)
        serializer.is_valid(raise_exception=True)
        self.perform_update(serializer)

        if getattr(instance, '_prefetched_objects_cache', None):
            # If 'prefetch_related' has been applied to a queryset, we need to
            # forcibly invalidate the prefetch cache on the instance.
            instance._prefetched_objects_cache = {}  # pylint: disable=protected-access

        return Response(serializer.data)
1189532
def clear_cache_fields(self):
        ''''''
        for field in self._meta.scalarfields:
            if field.as_cache:
                setattr(self, field.name, None)