get the model instance from the cache
516788
public Object getCache(ModelKey modelKey) {
		String modelClassName = null;
		if (modelKey.getModelClass() != null) {
			modelClassName = modelKey.getModelClass().getName();
			return modelCacheManager.getCache(modelKey.getDataKey(), modelClassName);
		} else
			return null;

	}
36253
def get_version(model_instance, version):
    
    version_field = get_version_fieldname(model_instance)
    kwargs = {'pk': model_instance.pk, version_field: version}
    return model_instance.__class__.objects.get(**kwargs)
673249
protected function getCacheInstance()
    {
        if (!$this->cache) {
            $this->cache = app($this->config('root.cache.instance'));
        }

        return $this->cache;
    }
1052023
def query_cache_by_object(self, zenpy_object):
        
        object_type = get_object_type(zenpy_object)
        cache_key = self._cache_key_attribute(object_type)
        return self.get(object_type, getattr(zenpy_object, cache_key))
1250138
def get_concrete_model(model):
    
    if not(inspect.isclass(model) and issubclass(model, models.Model)):
        model = get_model_by_name(model)

    return model
148278
def get_instance_of(self, model_cls):
        
        for obj in self.data.values():
            if isinstance(obj, model_cls):
                return obj
        LOGGER.error('Context Not Found')
        raise Exception('Context Not Found')
544462
def model_get(method_name):
    

    def model_get(_value, context, **_params):
        method = getattr(context["model"], method_name)
        return _get(method, context["key"], (), {})

    return model_get
660453
def _get(self, key):
        """"""
        self._populate_cache()
        if key not in self._cache:
            raise AttributeError("DataField has no member {}".format(key))

        return self._cache[key]
653193
def _get_serializable_model(cls):
        
        current_class = cls
        while current_class._meta.proxy:
            current_class = current_class._meta.proxy_for_model
        return current_class
942311
def fetch_object(self, model_id):
        """"""
        pk_field_instance = getattr(self.object_class, self.pk_field)
        qs = self.object_class.query.filter(pk_field_instance == model_id)
        model = qs.one_or_none()
        if not model:
            raise ReferenceNotFoundError
        return model
745038
def get_for_object(self, instance):
        
        # Return empty queryset if the given model instance is not a model instance.
        if not isinstance(instance, models.Model):
            return self.none()

        content_type = ContentType.objects.get_for_model(instance.__class__)
        pk = self._get_pk_value(instance)

        if isinstance(pk, integer_types):
            return self.filter(content_type=content_type, object_id=pk)
        else:
            return self.filter(content_type=content_type, object_pk=smart_text(pk))
33503
def generate_cache_key(cached, **kwargs):
    

    if isinstance(cached, QuerySet):
        key = str(cached.query)

    elif isinstance(cached, (Model, ModelBase)):
        key = '%s.%s:%s' % (cached._meta.app_label,
                            cached._meta.module_name,
                            ','.join('%s=%s' % item for item in kwargs.iteritems()))

    else:
        raise AttributeError("Objects must be queryset or model.")

    if not key:
        raise Exception('Cache key cannot be empty.')

    key = clean_cache_key(key)
    return key
1350963
def then_a_model_exists(context, model_name, key, value):
    
    model = apps.get_model(model_name)
    args = {
        key: value
    }
    obj = model.objects.get(**args)
    assert obj is not None
1221448
def get_instance(
    model, method="file",
    img_dir=None, data_dir=None,
    bucket=None
):
    """"""
    global _instances
    if not isinstance(model, ConsumeModel):
        raise TypeError(
            "get_instance() expects a parker.ConsumeModel derivative."
        )

    if method == "file":
        my_store = store.get_filestore_instance(
            img_dir=img_dir,
            data_dir=data_dir
        )
    elif method == "s3":
        my_store = store.get_s3store_instance(
            bucket=bucket
        )
    else:
        raise ValueError("Unexpected method value, '%s'." % method)

    key = "%s:%s" % (repr(model), repr(my_store))

    try:
        instance = _instances[key]
    except KeyError:
        instance = ConsumeStore(model, my_store)
        _instances[key] = instance

    return instance
450448
public void saveCache(Object dataKey, String modelClassName, Object model) {
		CacheKey cachKey = cacheKeyFactory.createCacheKey(dataKey.toString(), modelClassName);
		saveToCache(cachKey, model);
	}
184463
public Object getCache(Object dataKey, String modelClassName) {
		CacheKey cachKey = cacheKeyFactory.createCacheKey(dataKey.toString(), modelClassName);
		return getModelFromCache(cachKey);
	}
1125285
private ServiceDirectoryCache<String, ModelService> getCache(){
        if(cache == null){
            synchronized (this) {
                if (this.cache == null) {
                    this.cache = new ServiceDirectoryCache<String, ModelService>();
                }
            }
        }
        return this.cache;
    }