Change cache implementation. The contents of the old cache will
        be transferred to the new one.

        :param cache_impl: Name of cache implementation, must exist in AVAILABLE_CACHES
5837
def set_cache_impl(self, cache_impl, maxsize, **kwargs):
        
        new_cache = self._get_cache_impl(cache_impl, maxsize, **kwargs)
        self._populate_new_cache(new_cache)
        self.cache = new_cache
295784
def refresh_cache(self, if_want_update=False):
        """"""
        for thread in tuple(self._thread_cache.values()):
            if if_want_update:
                if not thread.want_update:
                    continue
            thread.update()
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
803320
def update_cache_for_instance(
        model_name, instance_pk, instance=None, version=None):
    """"""
    cache = SampleCache()
    invalid = cache.update_instance(model_name, instance_pk, instance, version)
    for invalid_name, invalid_pk, invalid_version in invalid:
        update_cache_for_instance.delay(
            invalid_name, invalid_pk, version=invalid_version)
679370
def _update_cache(self):
        
        expected_version = (
            tuple(r._version for r in self.registries) +
            (self._extra_registry._version, ))

        if self._last_version != expected_version:
            registry2 = Registry()

            for reg in self.registries:
                registry2.key_bindings.extend(reg.key_bindings)

            # Copy all bindings from `self._extra_registry`.
            registry2.key_bindings.extend(self._extra_registry.key_bindings)

            self._registry2 = registry2
            self._last_version = expected_version
48636
def updatable_map(cache: MutableMapping[Domain, Range]) -> Operator[Map]:
    

    def wrapper(function: Map[Domain, Range]) -> Map[Domain, Range]:
        @wraps(function)
        def wrapped(argument: Domain) -> Range:
            try:
                return cache[argument]
            except KeyError:
                result = function(argument)
                cache[argument] = result
                return result

        return wrapped

    return wrapper
785942
def _async_index_impl(self):
    """"""
    start = time.time()
    logger.info('TextPlugin computing index_impl() in a new thread')
    self._index_cached = self.index_impl()
    self._index_impl_thread = None
    self._index_impl_lock.release()
    elapsed = time.time() - start
    logger.info(
        'TextPlugin index_impl() thread ending after %0.3f sec', elapsed)
718947
def update_cache_for_course(self, courseid):
        
        to_drop = []
        for (cid, tid) in self._cache:
            if cid == courseid:
                to_drop.append(tid)
        for tid in to_drop:
            del self._cache[(courseid, tid)]
903324
private void injectCache(LongConsumer cacheAware) {
      if (cacheAware instanceof CacheAware) {
         ((CacheAware) cacheAware).injectCache(registry.getComponent(Cache.class));
      }
   }
107681
def add(self, val):
        
        return cache.lpush(self.key, json.dumps(val) if self.serialize else val)
358465
def update_cache(func):
    
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        """The wrapper function."""
        lazy = kwargs.get('lazy', False)
        kwargs.pop('lazy', None)

        if not lazy:
            self.get_json()

        ret = func(self, *args, **kwargs)

        # If returning a string assume it is an update message
        if isinstance(ret, str) and not lazy:
            self.set_json(ret)
        else:
            return ret

    return wrapper
930609
def reset(self):
        
        [a().remove_observer(self, self.on_cache_changed) if (a() is not None) else None for [a, _] in self.cached_input_ids.values()]

        self.order = collections.deque()
        self.cached_inputs = {}  # point from cache_ids to a list of [ind_ids], which where used in cache cache_id

        #=======================================================================
        # point from each ind_id to [ref(obj), cache_ids]
        # 0: a weak reference to the object itself
        # 1: the cache_ids in which this ind_id is used (len will be how many times we have seen this ind_id)
        self.cached_input_ids = {}
        #=======================================================================

        self.cached_outputs = {}  # point from cache_ids to outputs
        self.inputs_changed = {}
1240481
def set_implementation(self, impl):
        
        if impl.lower() == 'python':
            self.__impl__ = self.__IMPL_PYTHON__
        elif impl.lower() == 'c':
            self.__impl__ = self.__IMPL_C__
        else:
            import warnings
            warnings.warn('Implementation '+impl+' is not known. Using the fallback python implementation.')
            self.__impl__ = self.__IMPL_PYTHON__
927086
def connectCached(self, endpoint, protocolFactory,
                      extraWork=lambda x: x,
                      extraHash=None):
        
        key = endpoint, extraHash
        D = Deferred()
        if key in self.cachedConnections:
            D.callback(self.cachedConnections[key])
        elif key in self.inProgress:
            self.inProgress[key].append(D)
        else:
            self.inProgress[key] = [D]
            endpoint.connect(
                _CachingClientFactory(
                    self, key, protocolFactory,
                    extraWork))
        return D
649852
def step_impl(context, max_modified):
    
    assert len(context.buf) == len(context.fuzzed_buf)
    count = number_of_modified_bytes(context.buf, context.fuzzed_buf)
    assert count >= 0
    assert count <= max_modified
39885
def invalidate_cache(self, obj=None, queryset=None,
                         extra=None, force_all=False):
        

        if self.cache_manager:
            if queryset != None:
                force_all = True

            self.cache_manager.invalidate_cache(self.model, instance=obj,
                                                   extra=extra,
                                                   force_all=force_all)
671174
def commit(ref)
      if sha?(ref)
        get_cache(:commit, ref) { commit!(ref) }
      else
        if (sha = get_cache(:ref, ref))
          commit(sha)
        else
          if (cm = commit!(ref))
            set_cache(:ref, ref, cm.id)
            set_cache(:commit, cm.id, cm)
          end
        end
      end
    end