Function get

Hàm lấy dữ liệu cache

@author: 713uk13m <dev@nguyenanhung.com>
@time  : 10/12/18 18:09

@param string $key

@return bool|mixed|string|null
772387
public function get($key = '')
    {
        try {
            if ($this->cacheInstance !== NULL && is_object($this->cacheInstance)) {
                /**
                 * @var $cache object
                 */
                if (is_array($key)) {
                    $cache = $this->cacheInstance->getItems($key);
                } else {
                    $cache = $this->cacheInstance->getItem($key);
                }
                if (!$cache->isHit()) {
                    $result = NULL;
                    $this->debug->debug(__FUNCTION__, 'Unavailable Cache for Key: ' . $key);
                } else {
                    $result = $cache->get();
                    $this->debug->debug(__FUNCTION__, 'Get Cache from Key: ' . $key . ', result: ' . json_encode($result));
                }
                $message = 'Final get Content from Key: ' . $key . ' => Output result: ' . json_encode($result);
                $this->debug->info(__FUNCTION__, $message);

                return $result;
            } else {
                $this->debug->error(__FUNCTION__, 'Unavailable cacheInstance');

                return NULL;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return $message;
        }
    }
1094157
protected function objCacheGet($key)
    {
        if (isset($this->objCache[$key])) {
            return $this->objCache[$key];
        }
        return null;
    }
574607
public function get(string $key)
    {
        if (isset($this->inMemoryCache[$key])) {
            return $this->inMemoryCache[$key];
        }

        return $this->inMemoryCache[$key] = $this->laravelCache->get($key, null);
    }
733707
public function get( $key )
	{
		$prefixed = $this->prefix . $key;

		$cache = $this->table()->where( 'key', '=', $prefixed )->first();

		// If we have a cache record we will check the expiration time against current
		// time on the system and see if the record has expired. If it has, we will
		// remove the records from the database table so it isn't returned again.
		if ( !is_null( $cache ) )
		{
			if ( is_array( $cache ) )
				$cache = (object) $cache;

			if ( time() >= $cache->expiration )
			{
				$this->forget( $key );

				return null;
			}

			return $this->encrypter->decrypt( $cache->value );
		}

		return null;
	}
791976
public function get($key) {
		// First, check to see if the result has been cached.
		if (!isset($this->_cache[$key])) {
			return FALSE;
		}

		// Second, check its freshness.
		if ($this->_cache[$key]['time'] < time() - self::$_lifespan) {
			return FALSE;
		}

		return $this->_cache[$key]['data'];
	}
708113
public function get($key)
    {
        $key = $this->salted($key, $this->suffix);

        $cached = $this->cache->get($key);
        $code = $this->cache->getResultCode();

        if ($code === Memcached::RES_SUCCESS) {
            return $cached;

        } elseif ($code !== Memcached::RES_NOTFOUND) {
            $this->sendAlert('get', $key, $code);
        }

        return null;
    }
256427
public function getCacheTime($key)
    {
        $file=$this->getCacheDir().$key;
        if(file_exists($file))
            return filemtime($file);
            return null;
    }
576268
public function get($key) {
		
		if ($this->useFallback) {
			$filename = $this->getFileName($key);
			
			if (is_readable($filename)) {
				$fp = fopen($filename, "r");
				$timeout = fgets($fp);
					
				if ($timeout > time() || $timeout==0) {
					$contents = "";
					while (!feof($fp)) {
						$contents .= fread($fp, 65536);
					}
					fclose($fp);
					$value = unserialize($contents);
					//$this->log->trace("Retrieving key '$key' from file cache: value returned:".var_export($value, true));
					if ($this->log) {
						$this->log->trace("Retrieving key '$key' from file cache.");
					}
					return $value;
				} else {
					fclose($fp);
					unlink($filename);
					if ($this->log) {
						$this->log->trace("Retrieving key '$key' from file cache: key outdated, cache miss.");
					}
					return null;
				}
			} else {
				if ($this->log) {
					$this->log->trace("Retrieving key '$key' from file cache: cache miss.");
				}
				return null;
			}
		}
		
		// If not fallback
	
		$success = false;
		$value = apc_fetch($key, $success);
	
		if ($success) {
			if ($this->log) {
				$this->log->trace("Retrieving key '$key' from file cache.");
			}
			return $value;
		} else {
			if ($this->log) {
				$this->log->trace("Retrieving key '$key' from file cache: cache miss");
			}
			return null;
		}
	}
1253725
public function get($key)
    {
        if (!$this->isEnabled()) {
            return null;
        }

        $value = apc_fetch($this->prefix() . $key);

        return false === $value ? null : unserialize($value);
    }
249367
public function read($key) 
    {
        if (!$this->enabled) {
            return null;
        }
        
        $this->stats['execTimes'] ++;
        $this->stats['readTimes'] ++;
        
        $cachePath = $this->getCachePath($key);
        
        $this->waitUnlock($key);
        $data = $this->obj->get($cachePath);
        
        if (false !== $data) {
            $this->stats['readSize'] += strlen($data)/1024;
            $data = unserialize($data);
            return $data;
        }
    
        return null;
    }
44150
public function getByKey($key)
    {
        $storage = $this->getStorage();

        return isset($storage[$key]) ? $storage[$key] : null;
    }
722738
private function getSchemaCache($key)
    {
        if (isset($this->model_schema_cache[$key])) {
            return $this->model_schema_cache[$key];
        }

        return false;
    }
582406
protected function getCache($key)
    {
        if (array_key_exists($key, $this->cache)) {
            return $this->cache[$key];
        }
        return false;
    }
1350821
public function get($key)
    {
        $prefixed = $this->prefix.$key;

        $cache = $this->table()->where('key', '=', $prefixed)->first();

        // If we have a cache record we will check the expiration time against current
        // time on the system and see if the record has expired. If it has, we will
        // remove the records from the database table so it isn't returned again.
        if (is_null($cache)) {
            return;
        }

        $cache = is_array($cache) ? (object) $cache : $cache;

        // If this cache expiration date is past the current time, we will remove this
        // item from the cache. Then we will return a null value since the cache is
        // expired. We will use "Carbon" to make this comparison with the column.
        if (Carbon::now()->getTimestamp() >= $cache->expiration) {
            $this->forget($key);

            return;
        }

        return unserialize($cache->value);
    }
221173
public function get($key)
    {
        if (!$this->isEnabled()) {
            return null;
        }

        if (xcache_isset($this->prefix() . $key)) {
            return unserialize(xcache_get($this->prefix() . $key));
        } else {
            return null;
        }
    }
972285
public function get($key)
    {
        if (!$this->requireProvider("Getting key " . $key)) return false;

        return $this->cacheProvider->get($key);
    }
905196
public function get($key)
    {
        $key = $this->salted($key, $this->suffix);

        $raw = $this->predis->get($key);

        // every response should be a php serialized string.
        // values not matching this pattern will explode.
        // missing data should return null, which is not unserialized.

        if (is_string($raw)) {
            return unserialize($raw);
        }

        return $raw;
    }