Update the cache when an instance is deleted.
766123
def post_delete_update_cache(sender, instance, **kwargs):
    """"""
    name = sender.__name__
    if name in cached_model_names:
        from .tasks import update_cache_for_instance
        update_cache_for_instance(name, instance.pk, instance)
831207
def deleted(self, instance):
        
        self.session_manager.delete(instance, commit=True)
        return '', HTTPStatus.NO_CONTENT
1075238
function(obj, instance) {
                        var teardown;
                        // Setup a fresh mapping if `madeMap` is missing.
                        if (!madeMap) {
                            teardown = teardownMap;
                            madeMap = {};
                        }
                        // Record if Object has a `_cid` before adding one.
                        var hasCid = obj._cid;
                        var cid = can.cid(obj);

                        // Only update if there already isn't one already.
                        if (!madeMap[cid]) {

                            madeMap[cid] = {
                                obj: obj,
                                instance: instance,
                                added: !hasCid
                            };
                        }
                        return teardown;
                    }
165098
def _refresh_and_update(self):
        """"""
        # If the currently cached operation is done, no need to make another
        # RPC as it will not change once done.
        if not self._operation.done:
            self._operation = self._refresh()
            self._set_result_from_operation()
636988
def refresh(self, fields=None, **kwargs):
        
        cond = self.c[self._primary_field]==self._key
        query = self.filter(cond, **kwargs)
        if not fields:
            fields = list(self.table.c)
        
        v = query.values_one(*fields)
        if not v:
            raise NotFound('Instance <{0}:{1}> can not be found'.format(self.tablename, self._key))
        
        d = self._data_prepare(v.items())
        self.update(**d)
        self.set_saved()
25409
def updateCache(self, service, url, new_data, new_data_dt):
        
        key = self._get_key(service, url)

        # clear existing data
        try:
            value = self.client.get(key)
            if value:
                data = pickle.loads(value, encoding="utf8")
                if "time_stamp" in data:
                    cached_data_dt = parse(data["time_stamp"])
                    if new_data_dt > cached_data_dt:
                        self.client.delete(key)
                        # may raise MemcachedException
                        logger.info(
                            "IN cache (key: {}), older DELETE".format(key))
                    else:
                        logger.info(
                            "IN cache (key: {}), newer KEEP".format(key))
                        return
            else:
                logger.info("NOT IN cache (key: {})".format(key))

        except MemcachedException as ex:
            logger.error(
                "Clear existing data (key: {}) ==> {}".format(key, str(ex)))
            return

        # store new value in cache
        cdata, time_to_store = self._make_cache_data(
            service, url, new_data, {}, 200, new_data_dt)

        self.client.set(key, cdata, time=time_to_store)
        # may raise MemcachedException
        logger.info(
            "MemCached SET (key {}) for {:d} seconds".format(
                key, time_to_store))
630452
function () {
		var updateCache = this.cache;
		for (var i = 0, n = updateCache.length; i < n; i++)
			updateCache[i].update();
	}
1128267
function _updateSingleton() {
    if (!options.singletons) {
      return;
    }
    if (process.rebusinstances[folder]) {
      // Somebody added instance already.
      return;
    }
    // Save this instance to return the same for the same folder.
    process.rebusinstances[folder] = instance;
  }
1368636
def do_api_calls_update_cache(self):
        '''  '''
        zones = self.parse_env_zones()
        data = self.group_instances(zones)
        self.cache.write_to_cache(data)
        self.inventory = data
1066264
def _load_cache(self):
        """"""
        if not self._disable_cache:
            if os.path.exists(self._cache_path):
                _LOGGER.debug("Cache found at: %s", self._cache_path)
                if os.path.getsize(self._cache_path) > 0:
                    loaded_cache = UTILS.load_cache(self._cache_path)
                    UTILS.update(self._cache, loaded_cache)
                else:
                    _LOGGER.debug("Cache file is empty.  Removing it.")
                    os.remove(self._cache_path)

        self._save_cache()
76070
def update(self, cache):
        
        self.cache['delims'] = cache.get('delims')
        self.cache['opts'].update(cache.get('opts'))
        self.cache['rset'].update(cache.get('rset'))
        self.cache['mix'].update(cache.get('mix'))
        map(self.set_var, cache['ctx'].values())
367238
def cached(func, instance, args, kwargs):
    """"""
    cache = getattr(instance, "__cache", None)
    if cache is None:
        instance.__cache = cache = {}
    try:
        return cache[func]
    except KeyError:
        cache[func] = result = func(*args, **kwargs)
        return result
609901
def update(self, identifier, new_instance):
        
        with self.flushing():
            instance = self.retrieve(identifier)
            self.merge(instance, new_instance)
            instance.updated_at = instance.new_timestamp()
        return instance
199841
def reload(self, d=None):
        """"""
        if d:
            self.clear()
            self.update(d)
        elif self.id:
            new_dict = self.by_id(self._id)
            self.clear()
            self.update(new_dict)
        else:
            # should I raise an exception here?
            # Like "Model must be saved first."
            pass
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)
306649
def process_delete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs):
        """"""
        build_kwargs = self.delete_cache.take(obj)

        if build_kwargs:
            self.index.build(**build_kwargs)
502397
def _reset_values(self, instance):
        """"""
        self.value = None
        self.reference.value = None
        instance.__dict__.pop(self.field_name, None)
        instance.__dict__.pop(self.reference.field_name, None)
        self.reference.delete_cached_value(instance)