Set the object cache "notifyObjectCompiled" and "getBuffer"
        callbacks to the given Python functions.
486329
def set_object_cache(self, notify_func=None, getbuffer_func=None):
        
        self._object_cache_notify = notify_func
        self._object_cache_getbuffer = getbuffer_func
        # Lifetime of the object cache is managed by us.
        self._object_cache = _ObjectCacheRef(self)
        # Note this doesn't keep a reference to self, to avoid reference
        # cycles.
        ffi.lib.LLVMPY_SetObjectCache(self, self._object_cache)
1041365
def put(self, result, decorated_function, *args, **kwargs):
		
		self.__check(decorated_function, *args, **kwargs)

		ref = weakref.ref(args[0])
		if decorated_function not in self._storage:
			cache_entry = self._cache_record_cls.create(result, decorated_function, *args, **kwargs)
			self._storage[decorated_function] = [{'instance': ref, 'result': cache_entry}]
		else:
			instance_found = False
			for i in self._storage[decorated_function]:
				if i['instance']() == args[0]:
					cache_entry = i['result']
					cache_entry.update(result, *args, **kwargs)
					instance_found = True
					break
			if instance_found is False:
				cache_entry = self._cache_record_cls.create(result, decorated_function, *args, **kwargs)
				self._storage[decorated_function].append({'instance': ref, 'result': cache_entry})

		def finalize_ref():
			if decorated_function in self._storage:
				fn_list = self._storage[decorated_function]
				if len(fn_list) == 1 and fn_list[0]['instance'] == ref:
					del self._storage[decorated_function]

				for i in range(len(fn_list)):
					if fn_list[i]['instance'] == ref:
						fn_list.pop(i)
						return

		weakref.finalize(args[0], finalize_ref)
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
1129254
function makeCacheable(rawFunction) {
    var lastArguments;
    var currentArguments;
    var lastResult;
    var cacheFunction = function () {
        currentArguments = arguments;
        if (lastArguments == undefined || Array.prototype.some.call(lastArguments, function (value, index) {
            return value != currentArguments[index];
        })) {
            lastResult = rawFunction.apply(null, currentArguments);
            lastArguments = currentArguments;
        }
        return lastResult;
    };
    return cacheFunction;
}
464655
def __cache( self, method_name, *args, **kwargs ):
        
        trace_string           = util.get_stack(method_name)
        call_hash              = self.__get_hash(args, trace_string, kwargs)
        cd                     = call_descriptor.fetch( call_hash )
        if not cd:
            c  = self.__store__['callables'][method_name]
            if hasattr( c, '__class__' ) and c.__class__ == LazyBones:
                c = c.init()
            returnval = c(*args, **kwargs)
            cd = call_descriptor.CallDescriptor( hash      = call_hash,
                                                 stack     = trace_string,
                                                 method    = method_name,
                                                 returnval = returnval,
                                                 args      = args,
                                                 kwargs    = kwargs )
            cd.save()
            if not call_hash:
                raise Exception("CALL HASH IS NONE")

            util.last_hash = call_hash
            self.last_cached = call_hash
        else:
            returnval = cd.returnval

        if inspect.isclass(returnval):
            returnval = LazyBones( c, args, kwargs )

        return returnval
1330229
def with_cache(function):
        
        @wraps(function)
        def wrapped(cls, _cache_key, _cache_ignore, _cache_timeout, **kwargs):
            def clear_timeouts():
                """Clear the cache of timed out results."""
                for key in list(cls.timeouts):
                    if timer() - cls.timeouts[key] > _cache_timeout:
                        del cls.timeouts[key]
                        del cls.cache[key]

            if _cache_ignore:
                return function(cls, **kwargs)
            with cls.ca_lock:
                clear_timeouts()
                if _cache_key in cls.cache:
                    if cls.cache_hit_callback:
                        cls.cache_hit_callback(_cache_key)
                    return cls.cache[_cache_key]
            # Releasing the lock before actually making the request allows for
            # the possibility of more than one thread making the same request
            # to get through. Without having domain-specific caching (under the
            # assumption only one request to a domain can be made at a
            # time), there isn't a better way to handle this.
            result = function(cls, **kwargs)
            # The handlers don't call `raise_for_status` so we need to ignore
            # status codes that will result in an exception that should not be
            # cached.
            if result.status_code not in (200, 302):
                return result
            with cls.ca_lock:
                cls.timeouts[_cache_key] = timer()
                cls.cache[_cache_key] = result
                return result
        return wrapped
635917
def memoize_method(method):
    """"""
    cache = {}

    @functools.wraps(method)
    def wrapper(self, *args, **kwargs):
        """Caching wrapper."""
        key = (args, tuple(sorted(kwargs.items())))
        if key in cache:
            return cache[key]
        else:
            result = method(self, *args, **kwargs)
            cache[key] = result
            return result

    return wrapper
1166541
def _notify(self, func, *args, **kw):
        
        for x in self.listeners:
            try:
                getattr(x, func)(*args, **kw)
            except Exception:
                log.err()
1291179
def cached(func):
  
  class Cache(dict):
    def __missing__(self, key):
      result = self[key] = func(*key)
      return result
  cache = Cache()
  f = wraps(func)(lambda *key: cache[key])
  f.cache = cache
  return f
600672
def put_cache_results(self, key, func_akw, set_cache_cb):
        """"""
        args, kwargs = func_akw

        # get function results
        func_results = self.func(*args, **kwargs)

        # optionally add results to cache
        if set_cache_cb(func_results):
            self[key] = func_results
        return func_results
324337
def pool_memcached_connections(func):
    
    if isgeneratorfunction(func):
        def wrapper(*nargs, **kwargs):
            with memcached_client():
                for result in func(*nargs, **kwargs):
                    yield result
    else:
        def wrapper(*nargs, **kwargs):
            with memcached_client():
                return func(*nargs, **kwargs)

    return update_wrapper(wrapper, func)
926421
def context_cache(func):
    '''
    
    '''
    def context_cache_wrap(*args, **kwargs):
        func_context = func.__globals__['__context__']
        func_opts = func.__globals__['__opts__']
        func_name = func.__globals__['__name__']

        context_cache = ContextCache(func_opts, func_name)
        if not func_context and os.path.isfile(context_cache.cache_path):
            salt.utils.dictupdate.update(func_context, context_cache.get_cache_context())
        else:
            context_cache.cache_context(func_context)
        return func(*args, **kwargs)
    return context_cache_wrap
318722
def nocache(func):
    """"""

    def new_func(*args, **kwargs):
        """No cache Wrapper."""
        resp = make_response(func(*args, **kwargs))
        resp.cache_control.no_cache = True
        return resp

    return update_wrapper(new_func, func)
223227
def _raw_object_cache_notify(self, data):
        
        if self._object_cache_notify is None:
            return
        module_ptr = data.contents.module_ptr
        buf_ptr = data.contents.buf_ptr
        buf_len = data.contents.buf_len
        buf = string_at(buf_ptr, buf_len)
        module = self._find_module_ptr(module_ptr)
        if module is None:
            # The LLVM EE should only give notifications for modules
            # known by us.
            raise RuntimeError("object compilation notification "
                               "for unknown module %s" % (module_ptr,))
        self._object_cache_notify(module, buf)
78289
def cache(*args, **kwargs):
    
    ## only one argument ?
    if len(args) == 1 and len(kwargs) == 0 and \
           (callable(args[0]) or \
            isinstance(args[0], tuple(SUPPORTED_DECORATOR.keys()))):
        return _cache_w_args(args[0])
    return lambda f: _cache_w_args(f, *args, **kwargs)
1149556
def add_cache(self, object_type, cache_impl_name, maxsize, **kwargs):
        
        if object_type not in ZendeskObjectMapping.class_mapping:
            raise ZenpyException("No such object type: %s" % object_type)
        self.cache.mapping[object_type] = ZenpyCache(cache_impl_name, maxsize, **kwargs)
233790
def synchronise(func):
    
    def inner(request, *args):
        lock_id = '%s-%s-built-%s' % (
            datetime.date.today(), func.__name__,
            ",".join([str(a) for a in args]))

        if cache.add(lock_id, 'true', LOCK_EXPIRE):
            result = func(request, *args)
            cache.set(lock_id, result.task_id)
        else:
            task_id = cache.get(lock_id)
            if not task_id:
                return None

            cache.set(lock_id, "")
            result = Task.AsyncResult(task_id)
            if result.ready():
                result.forget()
                return None
        return result
    return inner