Get any facet that a composition falls into. Cached so successive
        calls at same composition are fast.
960990
def _get_facet_and_simplex(self, comp):
        
        c = self.pd_coords(comp)
        for f, s in zip(self.facets, self.simplexes):
            if s.in_simplex(c, PhaseDiagram.numerical_tol / 10):
                return f, s
        raise RuntimeError("No facet found for comp = {}".format(comp))
532092
private static LottieTask<LottieComposition> cache(
          @Nullable final String cacheKey, Callable<LottieResult<LottieComposition>> callable) {
    final LottieComposition cachedComposition = cacheKey == null ? null : LottieCompositionCache.getInstance().get(cacheKey);
    if (cachedComposition != null) {
      return new LottieTask<>(new Callable<LottieResult<LottieComposition>>() {
        @Override
        public LottieResult<LottieComposition> call() {
          return new LottieResult<>(cachedComposition);
        }
      });
    }
    if (cacheKey != null && taskCache.containsKey(cacheKey)) {
      return taskCache.get(cacheKey);
    }

    LottieTask<LottieComposition> task = new LottieTask<>(callable);
    task.addListener(new LottieListener<LottieComposition>() {
      @Override public void onResult(LottieComposition result) {
        if (cacheKey != null) {
          LottieCompositionCache.getInstance().put(cacheKey, result);
        }
        taskCache.remove(cacheKey);
      }
    });
    task.addFailureListener(new LottieListener<Throwable>() {
      @Override public void onResult(Throwable result) {
        taskCache.remove(cacheKey);
      }
    });
    taskCache.put(cacheKey, task);
    return task;
  }
129471
def cached_getter(func):
  """"""
  @wraps(func)
  def wrapper(self):
    attribute = f'_{func.__name__}'
    value = getattr(self, attribute, None)
    if value is None:
      value = func(self)
      setattr(self, attribute, value)
    return value
  return wrapper
435573
def get(self, request, *args, **kwargs):
        """"""

        form_class = self.get_form_class()
        form = self.get_form(form_class)

        top_value = self.get_top_level_facet_value()
        subfacets = SEARCH_SUBFACETS.get(top_value, [])
        self.active_facets = [self.top_facet] + subfacets

        if form.is_valid():
            self.query = form.cleaned_data.get(self.search_field)
        else:
            self.query = ""

        sqs = self.pre_facet_sqs()

        for facet in self.active_facets:
            sqs = facet.set_on_sqs(sqs)

        facet_counts = sqs.facet_counts()

        for facet in self.active_facets:
            facet.set_values_from_sqs_facet_counts(facet_counts)
            facet.apply_request_and_page_to_values(self.request, self.fluent_page)

        for facet in self.active_facets:
            sqs = facet.narrow_sqs(sqs)

        context = self.get_context_data(**{
            self.form_name: form,
            'facets': self.active_facets,
            'top_facet': self.top_facet,
            'query': self.query,
            'object_list': sqs,
            'page': self.fluent_page,
            'show_placeholders': self.show_placeholders()
        })
        return self.render_to_response(context)
1060369
def cached(func):
    
    cache = {}

    @f.wraps(func)
    def wrapper(*args, **kwargs):
        key = func.__name__ + str(sorted(args)) + str(sorted(kwargs.items()))
        if key not in cache:
            cache[key] = func(*args, **kwargs)
        return cache[key]
    return wrapper
783058
@SuppressWarnings("unchecked")
   private <F extends FACETTYPE> F safeGetFacet(Class<F> type)

   {
      for (FACETTYPE facet : facets)
      {
         if (type.isInstance(facet))
         {
            return (F) facet;
         }
      }
      return null;
   }
896003
def all(self, cache=False):
        
        if cache:
            return [get_object(self.modelb, obj_id, cache=True, use_local=True) for obj_id in self.keys(True)]
        else:
            return self
416521
def cached(fn, size=32):
    ''' '''
    assert callable(fn)
    assert isinstance(size, int)
    return overload(fn)(lru_cache(size, typed=True)(fn))
399225
def get(self, *args, **kwargs):
        
        clone = self.filter(*args, **kwargs)

        if self.query.can_filter():
            clone = clone.order_by()

        num = len(clone)

        if num == 1:
            return clone._result_cache[0]
        if not num:
            raise self.resource.DoesNotExist(
                "%s matching query does not exist. "
                "Lookup parameters were %s" %
                (self.resource._meta.resource_name, kwargs))

        raise self.resource.MultipleObjectsReturned(
            "get() returned more than one %s -- it returned %s! "
            "Lookup parameters were %s" %
            (self.resource._meta.resource_name, num, kwargs))
454936
def generic_key_facets(self, request):
        """"""

        excluded_apps = Q(app_label__in=EXCLUDED_APPS_FROM_FACETS)
        excluded_models = Q()
        for app_label, model in EXCLUDED_MODELS_FROM_FACETS:
            excluded_models = excluded_models | Q(app_label=app_label,
                    model=model)
        values = "model", "app_label", "id"
        content_types = ContentType.objects.values_list(*values) \
                .exclude(excluded_apps | excluded_models)
        return JsonResponse(dict([(str(a), {"app_label": str(b), "id": str(c)})
                for a, b, c in content_types]))
1161061
def get(self, index):
        
        if self and (index <= len(self) -1):
            return self._result_cache[index]
926684
def get_object_closure(subject, object_category=None, **kwargs):
    
    results = search_associations(subject=subject,
                                  object_category=object_category,
                                  select_fields=[],
                                  facet_fields=[M.OBJECT_CLOSURE],
                                  facet_limit=-1,
                                  rows=0,
                                  **kwargs)
    return set(results['facet_counts'][M.OBJECT_CLOSURE].keys())
1360531
def cached_instance(model, timeout=None, **filters):
    
    if isinstance(model, basestring):
        model = _str_to_model(model)

    cache_key = generate_cache_key(model, **filters)
    return get_cached(cache_key, model.objects.select_related().get, kwargs=filters)
1338738
public <T extends Facet> T getFacet(Class<T> type) {
        for (Facet f : facets)
            if(type==f.getClass())
                return type.cast(f);
        return null;
    }
198357
def raw_get(self, *raw_args, **raw_kwargs):
        

        args = self.prepare_args(*raw_args)
        kwargs = self.prepare_kwargs(**raw_kwargs)

        key = self.key(*args, **kwargs)

        return self.cache.get(key)
575086
def get(self, alias: str):
        
        try:
            return self._caches[alias]
        except KeyError:
            pass

        config = self.get_alias_config(alias)
        cache = _create_cache(**deepcopy(config))
        self._caches[alias] = cache
        return cache
1197838
def cache(cls, func):
        

        @functools.wraps(func)
        def func_wrapper(*args, **kwargs):
            func_key = cls.get_key(func)
            val_cache = cls.get_cache(func_key)
            lock = cls.get_cache_lock(func_key)

            return cls._get_value_from_cache(
                func, val_cache, lock, *args, **kwargs)

        return func_wrapper