public function GetCachedItem(string $propName, string $groupName, int $expiriesIn, $initFunc)
    {
        if (static::$DisableCache && $initFunc) {
            if (GnApi::$Debug) {
                GnLogger::Verbose("Cache is disable");
            }
            return $initFunc();
        }

        // In case memcached is not available, use no cache
        if (! static::$CacheHandler && ! $this->isMemcachedConnected() && $initFunc) {
            if (GnApi::$Debug) {
                GnLogger::Warning("No cache-handler configured and Memcached not available");
            }
            return $initFunc();
        }

        $val = static::$CacheHandler ? static::$CacheHandler->get($propName) : $this->_memcached->get($propName);
        if (! $val && $initFunc) {
            $val = $initFunc();
            if (static::$CacheHandler) {
                static::$CacheHandler->set($propName, $groupName, $val, $expiriesIn);
            } else {
                $this->_memcached->set($propName, $val, time() + $expiriesIn);
            }
        } elseif (GnApi::$Debug) {
            GnLogger::Verbose("Found cache '{$propName}'");
        }
        return $val;
    }
public function GetCachedItem(string $propName, string $groupName, int $expiriesIn, $initFunc)
    {
        if (static::$DisableCache && $initFunc) {
            if (GnApi::$Debug) {
                GnLogger::Verbose("Cache is disable");
            }
            return $initFunc();
        }

        // In case memcached is not available, use no cache
        if (! static::$CacheHandler && ! $this->isMemcachedConnected() && $initFunc) {
            if (GnApi::$Debug) {
                GnLogger::Warning("No cache-handler configured and Memcached not available");
            }
            return $initFunc();
        }

        $val = static::$CacheHandler ? static::$CacheHandler->get($propName) : $this->_memcached->get($propName);
        if (! $val && $initFunc) {
            $val = $initFunc();
            if (static::$CacheHandler) {
                static::$CacheHandler->set($propName, $groupName, $val, $expiriesIn);
            } else {
                $this->_memcached->set($propName, $val, time() + $expiriesIn);
            }
        } elseif (GnApi::$Debug) {
            GnLogger::Verbose("Found cache '{$propName}'");
        }
        return $val;
    }
public function GetCachedItem ( string $ propName , string $ groupName , int $ expiriesIn , $ initFunc ) { if ( static :: $ DisableCache && $ initFunc ) { if ( GnApi :: $ Debug ) { GnLogger :: Verbose ( "Cache is disable" ) ; } return $ initFunc ( ) ; } // In case memcached is not available, use no cache if ( ! static :: $ CacheHandler && ! $ this -> isMemcachedConnected ( ) && $ initFunc ) { if ( GnApi :: $ Debug ) { GnLogger :: Warning ( "No cache-handler configured and Memcached not available" ) ; } return $ initFunc ( ) ; } $ val = static :: $ CacheHandler ? static :: $ CacheHandler -> get ( $ propName ) : $ this -> _memcached -> get ( $ propName ) ; if ( ! $ val && $ initFunc ) { $ val = $ initFunc ( ) ; if ( static :: $ CacheHandler ) { static :: $ CacheHandler -> set ( $ propName , $ groupName , $ val , $ expiriesIn ) ; } else { $ this -> _memcached -> set ( $ propName , $ val , time ( ) + $ expiriesIn ) ; } } elseif ( GnApi :: $ Debug ) { GnLogger :: Verbose ( "Found cache '{$propName}'" ) ; } return $ val ; }
Returns a cached item

@param string $propName
@param string $groupName
@param int $expiriesIn
@param void $initFunc
@return object
Returns a cached item