Returns a cached data
@param string|array $cid
@param array $options
@return mixed
330297
public function get($cid, $options = array())
    {
        $options += array(
            'lifespan' => 0,
            'default' => null
        );

        $result = null;
        $this->hook->attach('cache.get.before', $cid, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        if (is_array($cid)) {
            $cid = gplcart_array_hash($cid);
        }

        $this->file = GC_DIR_CACHE . "/$cid.cache";

        $result = $options['default'];

        if (is_file($this->file)) {

            $this->filemtime = filemtime($this->file);

            if (empty($options['lifespan']) || ((GC_TIME - $this->filemtime) < $options['lifespan'])) {
                $result = unserialize(file_get_contents($this->file));
            }
        }

        $this->hook->attach('cache.get.after', $cid, $options, $result, $this);
        return $result;
    }
682286
public function get(array $options)
    {
        $options = $this->options($options);

        $response = $this->client->request('GET', $this->api_host.$this->api_prefix, $options);
        $content = $response->getBody()->getContents();

        $content = $this->repair->repair($content);
        $content = $this->detector->detect($content);

        return $content;
    }
1198067
public function run( $cid ) {

		if( isset( $this->model ) ) {

			$modelLocation = $this->modelLocationService->getById( $cid );

			if( isset( $modelLocation ) && $modelLocation->isParentValid( $this->model->id, $this->parentType ) ) {

				$location = $modelLocation->model;

				if( isset( $this->scenario ) ) {

					$location->setScenario( $this->scenario );
				}

				if( $location->load( Yii::$app->request->post(), $location->getClassName() ) && $location->validate() ) {

					$modelLocation->type = $this->modelType;

					$this->locationService->update( $location );

					$this->modelLocationService->update( $modelLocation );

					$location->refresh();

					$data = [
						'cid' => $modelLocation->id, 'type' => $modelLocation->type,
						'title' => $location->title,
						'country' => $location->countryName, 'province' => $location->provinceName,
						'region' => $location->regionName, 'city' => $location->cityName,
						'zip' => $location->zip, 'value' => $location->toString()
					];

					// Trigger Ajax Success
					return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
				}

				// Generate Errors
				$errors = AjaxUtil::generateErrorMessage( $location );

				// Trigger Ajax Failure
				return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
			}
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
827371
function get($resource, $query = array(), $headers = array()) {
        $url = $this->build_url($resource, $query);
        $key = $this->buildCacheKey('get', $resource, $url, $headers, $query);
        if (($this->cacher) && ($this->cacher->has($key))) return $this->cacher->get($key);
        $result = $this->client->get($url, [
            'headers' => array_merge([
                'Authorization' => $this->getBearer()
            ], $headers)
        ])->json();
        if ($this->cacher) $this->cacher->put($key, $result);
        return $result;
    }
80499
public function characteristicsReadItemIndex($cid) {
    $query = $this->connection->select('site_commerce_characteristics_item_index', 'n');
    $query->fields('n');
    $query->condition('cid', $cid);

    return $query->execute()->fetchObject();
  }
611940
public function getReadRequest($ids)
    {
        $cacheDataAdapter = $this->cacheDataAdapter; 
        $primaryKey = $this->primaryKey;
        return new StorageDataRequest(
            [$this->sourceDataAdapter, $this->cacheDataAdapter, $ids],
            function (DataAdapterInterface $sourceData, DataAdapterInterface $cacheData, $ids) {
                $request = $cacheData->getReadRequest($ids);
                $request->send();
                
                $cacheReadResult = $request->fetch();
                
                $cacheReadSuccess = count($cacheReadResult) == count($ids);
                if (!$cacheReadSuccess) {
                    $request = $sourceData->getReadRequest($ids);
                    $request->send();
                }
            
                return [$request, $cacheReadSuccess];
            },
            function (StorageDataRequest $request, $cacheReadSuccess) use ($cacheDataAdapter, $primaryKey) {
                $result = $request->fetch();
                if ($result && !$cacheReadSuccess) {
                    $cacheDataAdapter->getBatchInsertRequest($result)->send();
                }
                
                return $result;
            }
        );
    }
578082
protected function update($options = [])
    {
        $params = $this->prepareFields($options);
        $diff = $this->findDiff($params);
        $uri = static::getUri() . $this->{$this->primaryKey};

        $updateResult = static::put($this->client, $uri, [
            'json' => $diff,
        ]);

        if (!isset($updateResult['errors'])) {
            $this->cacheFields($params);
            foreach($updateResult as $name => $property) {
                $this->__set($name, $property);
            }
        }

        return $updateResult;
    }
536960
public function getData($options)
    {
        $this->checkRequiredParameters($options, [$this->optionsIdKey]);

        $transitions = $this->transitionResolver->getTransitions(
            $this->transitionKey,
            $options[$this->optionsIdKey]
        );

        /** @var TransitionResultInterface $transition */
        if (isset($transitions['previous'])) {
            foreach ($transitions['previous'] as $transition) {
                $this->addTransitionToEntries($transition);
            }
        }

        /** @var TransitionResultInterface $transition */
        $transition = $transitions['current'];
        $this->addTransitionToEntries($transition);

        if (isset($transitions['following'])) {
            /** @var TransitionResultInterface $transition */
            foreach ($transitions['following'] as $transition) {
                $this->addTransitionToEntries($transition);
            }
        }

        return parent::serializeData();
    }
1257182
public function json(array $data = array(), $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
    {

        if (!headers_sent())
        {
            header('Cache-Control: no-cache, must-revalidate');
            header('Expires: Tue, 19 May 1981 18:00:00 GMT');
            header('Content-type: application/json; charset=utf-8');
        }

        /**
         * @var \Deimos\Helper\Helpers\Json $json
         */
        $json = clone $this->helper->json();
        $json->setOption((array)$options);

        return $json->encode($data);

    }
915103
public static function find($id = null, array $options = array())
	{
		// deal with null valued PK's
		if (is_null($id))
		{
			// if no options are present, simply return null. a PK with a null value can exist
			return func_num_args() === 2 ? static::query($options) : null;
		}

		// Return all that match $options array
		elseif ($id === 'all')
		{
			return static::query($options)->get();
		}

		// Return first or last row that matches $options array
		elseif ($id === 'first' or $id === 'last')
		{
			$query = static::query($options);

			foreach(static::primary_key() as $pk)
			{
				$query->order_by($pk, $id == 'first' ? 'ASC' : 'DESC');
			}

			return $query->get_one();
		}

		// Return specific request row by ID
		else
		{
			$cache_pk = $where = array();
			$id = (array) $id;
			foreach (static::primary_key() as $pk)
			{
				$where[] = array($pk, '=', current($id));
				$cache_pk[$pk] = current($id);
				next($id);
			}

			if (array_key_exists(get_called_class(), static::$_cached_objects)
			    and array_key_exists(static::implode_pk($cache_pk), static::$_cached_objects[get_called_class()])
			    and (! isset($options['from_cache']) or $options['from_cache'] == true))
			{
				return static::$_cached_objects[get_called_class()][static::implode_pk($cache_pk)];
			}

			array_key_exists('where', $options) and $where = array_merge($options['where'], $where);
			$options['where'] = $where;
			return static::query($options)->get_one();
		}
	}
1302991
public function getData($options)
    {
        if ($this->checkRequiredParameters($options)) {
            $this->getOrderData($options);
            $this->getShipppingData($options);
            parent::orderDataByDate(false);

            return parent::serializeData();
        } else {
            throw new WidgetException('No params found!', $this->getName());
        }
    }
587335
public static function getCollectionPathFromID($cID)
    {
        $db = Database::connection();
        $path = $db->fetchColumn('select cPath from PagePaths inner join CollectionVersions on (PagePaths.cID = CollectionVersions.cID and CollectionVersions.cvIsApproved = 1) where PagePaths.cID = ? order by PagePaths.ppIsCanonical desc', array($cID));

        return $path;
    }
1212029
public function getMemcachedConnection(array $options = [])
    {
        $options = array_replace(['host' => 'localhost', 'port' => 11211], $options);
        if (null !== $cache = $this->getConnection('memcached', $options)) {
            return $cache;
        }

        if (!extension_loaded('memcached')) {
            throw new RuntimeException('The Memcached cache requires the Memcached extension.');
        }

        $memcached = new \Memcached();
        $memcached->addServer($options['host'], $options['port']);
        $memcached->getStats();

        if (\Memcached::RES_SUCCESS !== $memcached->getResultCode()) {
            throw new RuntimeException(sprintf("Memcached instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }

        return $this->setConnection('memcached', $options, $memcached);
    }
928465
public function getData(Options $options = null)
    {
        if ($options === null) {
            $options = $this->getOptions();
        }

        $select = $this->assignOptions(clone $this->getSelect(), $options);

        $sql = new Sql($this->adapter);

        $sql_string = $sql->buildSqlString($select);
        //echo $this->select->getSqlString($this->adapter->getPlatform());
        //echo "----" . var_dump($sql_string) . "----\n";
        // In ZF 2.3.0 an empty query will return SELECT .*
        // In ZF 2.4.0 and empty query will return SELECT *
        if (in_array($sql_string, ['', 'SELECT .*', 'SELECT *'], true)) {
            throw new Exception\EmptyQueryException(__METHOD__ . ': Cannot return data of an empty query');
        }
        $this->query_string = $sql_string;

        try {
            $results = $this->adapter->query($sql_string, Adapter::QUERY_MODE_EXECUTE);
            //$stmt = $sql->prepareStatementForSqlObject( $select );
            //$results = $stmt->execute();
            //var_dump(get_class($results));

            $r = new ResultSet($results);
            $r->setSource($this);
            $r->setHydrationOptions($options->getHydrationOptions());

            if ($options->hasLimit() && $options->getLimit() > 0) {
                //$row = $this->adapter->query('select FOUND_ROWS() as total_count')->execute()->current();
                $row = $this->adapter->createStatement('select FOUND_ROWS() as total_count')->execute()->current();
                $r->setTotalRows($row['total_count']);
            } else {
                $r->setTotalRows($r->count());
            }
        } catch (\Exception $e) {
            throw new Exception\ErrorException(__METHOD__ . ': Cannot retrieve data (' . $e->getMessage() . ')');
        }

        return $r;
    }
721360
public function getStorage(
        string $storage,
        array $options = [],
        string $name = 'windwalker'
    ): CacheItemPoolInterface {
        $class = class_exists($storage)
            ? $storage
            : sprintf('Windwalker\Cache\Storage\%sStorage', StringNormalise::toCamelCase($storage));

        if (!class_exists($class)) {
            throw new \DomainException(sprintf('Cache Storage: %s not supported.', ucfirst($storage)));
        }

        $config = Ioc::getConfig();

        $options['cache_time']  = $options['cache_time'] ?? $config->get('cache.time');
        $options['cache_dir']   = $options['cache_dir'] ?? $config->get('path.cache');
        $options['deny_access'] = $options['deny_access'] ?? $config->get('cache.denyAccess');

        // Convert seconds to minutes
        $options['cache_time'] *= 60;

        switch (strtolower($storage)) {
            case 'file':
            case 'php_file':
            case 'forever_file':
                return $this->createFileStorage($name, $class, $options);
                break;

            case 'redis':
            case 'memcached':
                return $this->container->newInstance(
                    $class,
                    [null, $options['cache_time'], $options]
                );
                break;

            default:
                if ($storage === FileStorage::class || is_subclass_of($storage, FileStorage::class)) {
                    return $this->createFileStorage($name, $class, $options);
                }

                return $this->container->newInstance(
                    $class,
                    [$options['cache_time'], $options]
                );
                break;
        }
    }
844500
public static function getDI(array $paths, array $options): ?ContainerInterface
    {
        $class = $options['class'] ?? '';
        if (!$class) {
            return null;
        }

        $cacheDisabled = getenv(static::ENV_CACHE_DISABLED);
        if ($cacheDisabled) {
            return self::buildContainer($paths, $class, $options);
        }

        return self::getCachedContainer($class);
    }
1290015
public function set_data_to_cache($value, $option = null, $duration = 0)
    {
        return $this->getDatabox()->set_data_to_cache($value, $this->get_cache_key($option), $duration);
    }