Cache a value from the given callback based on the current class name, the given key and the configured cache
lifetime.

@param  string  $key
@param  callable  $function
@return string
766086
protected function remember($key, callable $function)
    {
        $class = new ReflectionClass($this);
        $class = $class->getShortName();

        $lifetimes = config('forum.preferences.cache_lifetimes');
        $lifetime = isset($lifetimes[$class][$key]) ? $lifetimes[$class][$key] : $lifetimes['default'];

        return Cache::remember($class.$this->id.$key, $lifetime, $function);
    }
1254971
protected function getCache($key, $default)
    {
        if (!isset($this->cache[$key])) {
            $this->cache[$key] = is_callable($default) ? $default() : $default;
        }
        return $this->cache[$key];
    }
597824
public static function getCached($function)
    {
        $returnValue = null;

        
		$args = func_get_args();
		array_shift($args);
        if (!is_string($function)){
            $r = new ReflectionFunction($function);
            $serial = md5(
              $r->getFileName().
              $r->getStartLine().
              serialize($args)
            );
        } else {
            $serial = md5($function.serialize($args));
        }
        if (static::singleton()->has($serial)) {
        	$returnValue = static::singleton()->has($serial);
        } else { 
	        $returnValue = call_user_func_array($fn, $args);
	        static::singleton()->put($serial, $returnValue);
        }
        

        return $returnValue;
    }
1020145
protected function getCachedValue($key)
    {
        $this->cache->setPrefix($this->dataProvider->getCachePrefix());
        return $this->cache->get($key);
    }
259169
public function remember($key, \Closure $callback)
    {
        if (! $this->cacheIsEnabled()) {
            return $callback();
        }

        $key = config('health.cache.key').$key;

        $this->flush(false, $key);

        return IlluminateCache::remember($key, $this->getMinutes(), $callback);
    }
1289985
public function resolveCallableFromCache(string $name, callable $closure)
    {
        if($this->cache->has(self::CACHE_CALLABLE . $name)) {
            return $this->cache->get(self::CACHE_CALLABLE . $name);
        }

        $resolved = $this->resolveCallable($name, $closure);

        //cache closure
        $this->store(self::CACHE_CALLABLE . $name, $resolved);

        return $resolved;
    }
989458
private function remember($key, Closure $callback)
    {
        $value = $this->cache->get($key);

        if ($value !== null) {
            return $value;
        }

        $this->cache->set($key, $value = $callback());

        return $value;
    }
920533
public static function call($key, callable $func)
    {
        $trace = debug_backtrace();
        if ($function = $trace[1]["function"]) {
            $key = $function . "_" . $key;
            if ($class = $trace[1]["class"]) {
                $key = str_replace("\\", "_", $class) . "_" . $key;
            }
        }

        if (static::check($key)) {
            return static::get($key);
        }

        $return = $func();

        static::set($key, $return);

        return $return;
    }
353285
protected function reset(string $name, callable $callback = null)
    {
        if (!isset($this->cache[$name])) {
            return;
        }

        if ($callback !== null) {
            call_user_func($callback, $name, $this->cache[$name]);
        }

        unset($this->cache[$name]);
    }
1235167
public function bind(callable $function) : Monadic
    {
        return new self(function ($state) use ($function) {
            list($initial, $final) = $this->run($state);

            return $function($initial)->run($final);
        });
    }
736354
def get_cache(self, decorated_function, *args, **kwargs):
		
		has_value = self.has(decorated_function, *args, **kwargs)
		cached_value = None
		if has_value is True:
			cached_value = self.get_result(decorated_function, *args, **kwargs)
		return WCacheStorage.CacheEntry(has_value=has_value, cached_value=cached_value)
1118850
public static function allowExcessiveArguments(callable $function)
    {
        $reflection = Reflection::fromCallable($function);
        if ($reflection->isUserDefined()) {
            return $function;
        }

        if (Reflection::isVariadic($reflection)) {
            return $function;
        }

        $numberOfArguments = $reflection->getNumberOfParameters();

        $argumentLimiter = function () use ($function, $numberOfArguments) {
            return call_user_func_array($function, array_slice(func_get_args(), 0, $numberOfArguments));
        };

        /*
         * If there are default values, just use the default closure to
         * ensure correct default values are used for unsupplied arguments.
         */
        if ($numberOfArguments !== $reflection->getNumberOfRequiredParameters()) {
            return $argumentLimiter;
        }

        /*
         * Micro-optimization: provide simple wrappers for internal functions
         * with simple signatures rather than the more costly argument array slicing.
         */
        switch ($numberOfArguments) {
            case 0:
                return function () use ($function) {
                    return $function();
                };

            case 1:
                return function ($a) use ($function) {
                    return $function($a);
                };

            case 2:
                return function ($a, $b) use ($function) {
                    return $function($a, $b);
                };

            case 3:
                return function ($a, $b, $c) use ($function) {
                    return $function($a, $b, $c);
                };

            case 4:
                return function ($a, $b, $c, $d) use ($function) {
                    return $function($a, $b, $c, $d);
                };

            default:
                return $argumentLimiter;
        }
    }
622941
public static function getKey($callable)
    {
        /** @var string|null $class */
        $class = null;
        /** @var string|null $method */
        $method = null;

        if (is_string($callable)) {
            $method = $callable; // works for 'Cls::method' case as well
        } elseif (is_array($callable)) {
            $class = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
            $method = $callable[1];
        } elseif (is_object($callable)) {
            if ($callable instanceof \ReflectionFunctionAbstract) {
                if ($callable->isClosure()) {
                    return null;
                }

                $class = $callable instanceof \ReflectionMethod ? $callable->class : null;
                $method = $callable->name;
            } else {
                if ($callable instanceof \Closure) {
                    return null;
                }

                $class = get_class($callable);
                $method = '__invoke';
            }
        }

        return strtolower(($class ? $class . '::' : '') . $method);
    }
806153
public function getOnce($key, Closure $callback)
    {
        if ($this->has($key)) {
            return $this->cookies[$key];
        } else {
            $value = $callback();
            $this->set($key, $value);

            return $value;
        }
    }
721940
public function getCache($key) {
        if($this->modified === true || !$this->cacheEnabled) {return false;}
        else{
            $this->cacheValue = $this->cacheObj->fetch($key);
            return $this->cacheValue;
        }
    }
277111
private function performCallbackOnCachedPersister(callable $callback)
    {
        if (! $this->hasCache) {
            return;
        }

        foreach (array_merge($this->entityPersisters, $this->collectionPersisters) as $persister) {
            if ($persister instanceof CachedPersister) {
                $callback($persister);
            }
        }
    }
546495
protected function get(string $name, callable $callback)
    {
        if (isset($this->cache[$name])) {
            return $this->cache[$name];
        }

        return $this->cache[$name] = call_user_func($callback, $name);
    }