Make the given method a per-request cached property.

    This caches the value on the request context rather than on the object
    itself, preventing problems if the object gets reused across multiple
    requests.
485270
def request_cached_property(func):
    
    @property
    @functools.wraps(func)
    def wrapped(self):
        cached_value = context.get_for_view(self, func.__name__, UNDEFINED)
        if cached_value is not UNDEFINED:
            return cached_value

        value = func(self)
        context.set_for_view(self, func.__name__, value)

        return value

    return wrapped
597877
def cached_method(func):
    
    @functools.wraps(func)
    def wrapper(self, *args):
        if not hasattr(self, "_cache"):
            self._cache = {}
        key = _argstring((func.__name__,) + args)
        if key not in self._cache:
            self._cache[key] = func(self, *args)
        return self._cache[key]
    return wrapper
421803
def set(self, key, value, **kw):
        

        self.impl.set(key, value, **self._get_cache_kw(kw, None))
875491
def _set_request_cache_if_django_cache_hit(key, django_cached_response):
        
        if django_cached_response.is_found:
            DEFAULT_REQUEST_CACHE.set(key, django_cached_response.value)
708320
public void cache(String key, Object o, int ttl, Object... args) {
        if (conf().cacheDisabled()) return;
        ICacheService cacheService = _cacheService;
        Serializable value = null == o ? "" : (o instanceof Serializable ? (Serializable) o : o.toString());
        if (args.length > 0) {
            StringBuilder sb = new StringBuilder(key);
            for (Object arg : args) {
                sb.append("-").append(arg);
            }
            key = sb.toString();
        }
        cacheService.put(key, value, ttl);
    }
193388
def cached_property(prop):
    
    def cache_wrapper(self):
        if not hasattr(self, "_cache"):
            self._cache = {}
        if prop.__name__ not in self._cache:
            return_value = prop(self)
            if isgenerator(return_value):
                return_value = tuple(return_value)
            self._cache[prop.__name__] = return_value
        return self._cache[prop.__name__]
    return property(cache_wrapper)
783056
def set_cache(self, request, response):
        

        try:
            cache_key = self.cache_key(request)
            #presumably this is to deal with requests with attr functions that won't pickle
            if hasattr(response, 'render') and callable(response.render):
                response.add_post_render_callback(lambda r: cache.set(cache_key, (r, time.time(),), settings.BETTERCACHE_LOCAL_MAXAGE))
            else:
                cache.set(cache_key, (response, time.time(),) , settings.BETTERCACHE_LOCAL_MAXAGE)
        except:
            logger.error("failed to cache to %s" %cache_key)
861627
def flush_cache(self, properties=None):
        
        if hasattr(self, '_cache'):
            if properties is None:
                del(self._cache)
            else:
                for prop in properties:
                    if prop in self._cache:
                        del(self._cache[prop])
632391
def _lazy(self, method, *args):
        
        if list.__len__(self) == 0:
            self.load()
            setattr(self, method, types.MethodType(getattr(list, method), self))
        return getattr(list, method)(self, *args)
182347
public static void putOverloadMethodCache(String serviceName, Method method) {
        ConcurrentHashMap<String, Method> cache = OVERLOAD_METHOD_CACHE.get(serviceName);
        if (cache == null) {
            cache = new ConcurrentHashMap<String, Method>();
            ConcurrentHashMap<String, Method> old = OVERLOAD_METHOD_CACHE.putIfAbsent(serviceName, cache);
            if (old != null) {
                cache = old;
            }
        }
        StringBuilder mSigs = new StringBuilder(128);
        mSigs.append(method.getName());
        for (Class<?> paramType : method.getParameterTypes()) {
            mSigs.append(paramType.getName());
        }
        cache.putIfAbsent(mSigs.toString(), method);
    }
70138
function addMethod(key) {
  Cacher.prototype[key] = function() {
    if (!this.md) {
      return Promise.reject(new Error('Model not set'));
    }
    this.method = key;
    return this.run.apply(this, arguments);
  };
}
1084437
public static void putMethodCache(String serviceName, Method method) {
        ConcurrentHashMap<String, Method> cache = NOT_OVERLOAD_METHOD_CACHE.get(serviceName);
        if (cache == null) {
            cache = new ConcurrentHashMap<String, Method>();
            ConcurrentHashMap<String, Method> old = NOT_OVERLOAD_METHOD_CACHE.putIfAbsent(serviceName, cache);
            if (old != null) {
                cache = old;
            }
        }
        cache.putIfAbsent(method.getName(), method);
    }
523521
function (property) {

                    this.factory.chainCache = this.factory.chainCache || {};

                    if (this.factory.chainCache[property]) {
                        return this.factory.chainCache[property];
                    }

                    var ret = this[property],
                        base = this.base;

                    while (base) {
                        var baseValue = base[property];
                        for (var key in baseValue) {
                            if (baseValue.hasOwnProperty(key)) {
                                if (_.isUndefined(ret[key])) {
                                    ret[key] = baseValue[key];
                                }
                            }
                        }

                        base = base.base;
                    }

                    // cache the chain
                    this.factory.chainCache[property] = ret;

                    return ret;
                }
725496
def cached_property(**kwargs):
    """"""
    def decorator(function):
        @wraps(function)
        def wrapper(self):
            key = 'fandjango.%(model)s.%(property)s_%(pk)s' % {
                'model': self.__class__.__name__,
                'pk': self.pk,
                'property': function.__name__
            }

            cached_value = cache.get(key)

            delta = timedelta(**kwargs)

            if cached_value is None:
                value = function(self)
                cache.set(key, value, delta.days * 86400 + delta.seconds)
            else:
                value = cached_value

            return value
        return wrapper
    return decorator
361999
public void cache(String key, Object obj, int expiration) {
        H.Session session = this.session;
        if (null != session) {
            session.cache(key, obj, expiration);
        } else {
            app().cache().put(key, obj, expiration);
        }
    }
787439
def cached(method):
    
    _cache_attr_name = '_cache_'+method.__name__
    _bool_attr_name  = '_cached_'+method.__name__
    def method_wrapper(self,*args,**kwargs):
        is_cached = getattr(self,_bool_attr_name)
        if not is_cached:
            result = method(self, *args, **kwargs)
            setattr(self, _cache_attr_name, result)
            setattr(self, _bool_attr_name, True)
        return getattr(self,'_cache_'+method.__name__)
    return method_wrapper
1341101
public ObjectCacheDef setObjectCache(String name)
    {
        if ((_objectCache == null) || !_objectCache.getName().equals(name))
        {    
            _objectCache = new ObjectCacheDef(name);
    
            _objectCache.setOwner(this);
        }
        return _objectCache;
    }