设置缓存接口
@param $key
@param $data
@param $period
@param $config
@return mixed
165401
public static function set($key,$data,$period,$config)
    {
        static::initRedis();
        /**
         * 确定key
         */
        static::$key = $key;
        if(is_array($key) && count($key) == 2){
            static::$group = $key[0];
            static::$key = $key[1];
        }
        static::$md5key =  md5(static::$key );
        /**
         * 判断是删除缓存还是设置缓存
         */
        if($data == null){
            /**
             * 删除缓存
             */
            $returnData = static::$Redis->del('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key);
        }else{
            /**
             * 设置缓存  准备数据
             */
            static::$data = serialize($data);
            /**
             * $typeCache  缓存类型  拼接  分组   =  表名称
             */
            $returnData = static::$Redis->set('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key,static::$data);
            if($period !=0){
                $returnData = static::$Redis->expire('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key,$period);
            }
        }
        static ::staticEmpty();
        return $returnData;
    }
401635
public static function groupBy($data, $key)
    {
        $res = [];
        for ($i = 0, $l = sizeof($data); $i < $l; $i++) {
            $item = $data[$i];
            $value = empty($item[$key]) ? __undefined : $item[$key];
            if (empty($res[$value])) {
                $res[$value] = [];
            }
            $res[$value][] = $item;
        }
        return $res;
    }
36710
public function setData($data, $key = null)
	{
		if (is_array($data) && $key === null) {
			$this->data = $data;

			return $this;
		}

		if ($key === null)
			$key = 'data';

		$this->data[$key] = $data;

		return $this;
	}
161833
public static function createFromArray($key, array $data = [])
    {
        $webFormBody = new static($key);

        if (isset($data['formParameters'])) {
            foreach ($data['formParameters'] as $namedParam => $namedParamData) {
                if (\is_array($namedParamData)) {
                    $webFormBody->addParameter(NamedParameter::createFromArray($namedParam, $namedParamData));
                }
            }
        }

        return $webFormBody;
    }
132835
private function createManyToOneRelation(array &$data, $key)
    {
        $uid = isset($data[$key]) ? (int)$data[$key] : 0;

        $data[$key] = ($uid > 0)
            ? \Tx_Oelib_MapperRegistry::get($this->relations[$key])->find($uid)
            : null;
    }
1161893
public function set(string $field, string $key, $data, int $expire = self::EXPIRE): bool
    {
        // 缓存数据
        $this->doSet($key, $data, $expire);

        //记录调试信息
        self::debugSet($field . ':' . $key, $data);

        // 取出此表已经缓存的所有键
        $keys = $this->get(self::PREFIX_FIELD . $field);
        if (!$keys or $keys == CacheFactory::NOT_FOUND) {
            $keys = [];
        }

        // 增加一个键,并保存回去,以便以后统一清除
        $keys[] = $key;
        return $this->doSet(self::PREFIX_FIELD . $field, $keys, $expire);
    }
435833
public function get($key, $default = null, $mode = self::HAS_ISSET)
    {
        if (!$this->has($key, $mode)) {
            return $default;
        }

        $key = $this->normalizeKey($key);

        return $this->data[$key];
    }
85273
public function getSalesData( $duration, $config = [] ) {

		$transactions	= [];
		$transactionskv = [];

		$dates	= [];
		$amount	= [];

		$base		= isset( $config[ 'base' ] ) ? $config[ 'base' ] : false;
		$children	= isset( $config[ 'children' ] ) ? $config[ 'children' ] : false;

		$statusComplete	= Order::STATUS_COMPLETED;

		$txnTable	= Yii::$app->get( 'transactionService' )->getModelTable();
		$orderTable	= Yii::$app->get( 'orderService' )->getModelTable();

		$query = new Query();

		$query->select( [ "date(`$txnTable`.`createdAt`) as date", 'sum( amount ) as amount' ] );
		$query->from( $txnTable );

		$query->join( 'LEFT JOIN', $orderTable, "orderId = `$orderTable`.`id`" );
		$query->where( " $orderTable.status=$statusComplete" );

		if( $base ) {

			$query->andWhere( " $orderTable.baseId IS NULL" );
		}
		else if( $children ) {

			$query->andWhere( " $orderTable.baseId IS NOT NULL" );
		}

		switch( $duration ) {

			case 0: {

				// Current Week - Starting with Sun
				$dates = DateUtil::getCurrentWeekDates();

				$transactions = $query->andWhere( "YEARWEEK( `$txnTable`.`createdAt` ) = YEARWEEK( CURRENT_DATE ) " )
								->groupBy( [ 'date' ] )
								->all();

				break;
			}
			case 1: {

				// Last Week - Starting with Sun
				$dates = DateUtil::getLastWeekDates();

				$transactions = $query->andWhere( "YEARWEEK( `$txnTable`.`createdAt` ) = YEARWEEK( CURRENT_DATE - INTERVAL 7 DAY ) " )
								->groupBy( [ 'date' ] )
								->all();

				break;
			}
			case 2: {

				// This Month
				$dates = DateUtil::getCurrentMonthDates();

				$transactions = $query->andWhere( "MONTH( `$txnTable`.`createdAt` ) = ( MONTH( NOW() ) ) AND YEAR( `$txnTable`.`createdAt` ) = YEAR( NOW() ) " )
								->groupBy( [ 'date' ] )
								->all();

				break;
			}
			case 3: {

				// Last Month
				$dates = DateUtil::getLastMonthDates();

				$transactions = $query->andWhere( "MONTH( `$txnTable`.`createdAt` ) = ( MONTH( NOW() ) - 1 ) AND YEAR( `$txnTable`.`createdAt` ) = YEAR( NOW() ) " )
								->groupBy( [ 'date' ] )
								->all();

				break;
			}
		}

		foreach( $transactions as $transaction ) {

			$transactionskv[ $transaction[ 'date' ] ] = $transaction[ 'amount' ];
		}

		foreach( $dates as $date ) {

			if( isset( $transactionskv[ $date ] ) ) {

				$amount[] = $transactionskv[ $date ];
			}
			else {

				$amount[] = 0;
			}
		}

		return $amount;
	}
175079
protected function createJsonResponse(array $data, array $config)
    {
        if (! \is_null($uses = $config['uses'] ?? null)) {
            $data = $data[$uses] ?? [];
        }

        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        $data = \array_map([$this, 'transformToArray'], $data);

        return function () use ($data, $config) {
            return \json_encode($data, $config['encoding'] ?? 0);
        };
    }
405590
public function setData($key, $data, $registry = null)
	{
		if ($registry == null) {
			$registry = $this->default;
		}
		if (is_string($key . $registry) && $this->registryExists($registry)) {
			$this->data[self::REGISTRY][$registry][$key] = $data;
			$this->dirty = true;
			return true;
		}
		return false;
	}
520882
public static function get($key, $config_name = 'main')
    {
        // 获取值
        // 加载其他配制文件
        if ($config_name !== 'main' && !isset(self::$_config[$config_name])) {
            $filename = APP_PATH . '/conf/' . $config_name . '.php';
            if (file_exists($filename)) {
                self::$_config[$config_name] = include $filename;
            } else {
                \show_error("Config file {$filename} is not exists.");
            }
        }

        // 返回需要value
        if ($key === '') {
            return self::$_config[$config_name];
        } elseif (array_key_exists($key, self::$_config[$config_name])) {
            return self::$_config[$config_name][$key];
        } elseif (strpos($key, '.')) {
            $array = explode('.', $key);
            if (count($array) === 2) {
                return isset(self::$_config[$config_name][$array[0]][$array[1]]) ? self::$_config[$config_name][$array[0]][$array[1]] : false;
            } elseif (count($array) === 3) {
                return isset(self::$_config[$config_name][$array[0]][$array[1]][$array[2]]) ? self::$_config[$config_name][$array[0]][$array[1]][$array[2]] : false;
            } else {
                show_error('Config::get("a.b.c") Only 3 levels are allowed.');
            }
        } else {
            return false;
        }
    }
217956
public function storageLogin($key, $data, $expire = 0)
    {
        $ticket = md5(time() . rand(1000, 9999) . serialize($data));
        $key = $this->getKey($key);
        
        // 设置Cookie
        Cookie::set($key, $ticket, $expire);
        
        // 缓存数据
        Cache::set($ticket, $data, $expire);
    }
1150567
protected function hasForPeriod($key, \DatePeriod $period)
    {
        $ranges = $this->getRanges($period);

        if (count($ranges) > 0) {
            if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) {
                return new DateExists($ranges[0], $this->repository->hasFor($key, $ranges[0]));
            }

            $values = array();

            /** @var \Krucas\Counter\DateRange $range */
            foreach ($ranges as $range) {
                $values[] = new RangeExists(
                    $range,
                    $this->repository->hasForRange($key, $range->getStartDate(), $range->getEndDate())
                );
            }

            return $values;
        }

        return new Exists(false);
    }
776379
private static function getConfigValue($key, $config)
    {
        $config = ($config && is_array($config)) ? $config : BlockCypherConfigManager::getInstance()->getConfigHashmap();
        return (array_key_exists($key, $config)) ? trim($config[$key]) : null;
    }
365074
protected function decreaseRateLimitRemaining(string $key, int $limit, int $period)
    {
        $cost = 1;
        $currentTime = gmdate('U');

        $rateLimitInfo = $this->cacheItemPool->getItem($key);
        $rateLimit = $rateLimitInfo->get();
        if ($rateLimitInfo->isHit() && $currentTime <= $rateLimit['reset']) {
            // decrease existing rate limit remaining
            if ($rateLimit['remaining'] - $cost >= 0) {
                $remaining = $rateLimit['remaining'] - $cost;
                $reset = $rateLimit['reset'];
                $ttl = $rateLimit['reset'] - $currentTime;
            } else {
                $this->rateLimitExceeded = true;
                $this->reset = $rateLimit['reset'];
                $this->limit = $limit;
                $this->remaining = 0;

                return;
            }
        } else {
            // add / reset new rate limit remaining
            $remaining = $limit - $cost;
            $reset = $currentTime + $period;
            $ttl = $period;
        }

        $rateLimit = [
            'limit' => $limit,
            'remaining' => $remaining,
            'reset' => $reset,
        ];

        $rateLimitInfo->set($rateLimit);
        $rateLimitInfo->expiresAfter($ttl);

        $this->cacheItemPool->save($rateLimitInfo);

        $this->limit = $limit;
        $this->remaining = $remaining;
        $this->reset = $reset;
    }
918495
public static function createFromArray($key, array $data = [])
    {
        $describedBy = new static($key);

        if (isset($data['body'])) {
            foreach ($data['body'] as $key => $bodyData) {
                $body = \in_array($key, \Raml\WebFormBody::$validMediaTypes, true) ? \Raml\WebFormBody::createFromArray($key, $bodyData) : \Raml\Body::createFromArray($key, $bodyData);

                $describedBy->addBody($body);
            }
        }

        if (isset($data['headers'])) {
            foreach ($data['headers'] as $key => $header) {
                $describedBy->addHeader(NamedParameter::createFromArray($key, $header));
            }
        }

        if (isset($data['queryParameters'])) {
            foreach ($data['queryParameters'] as $key => $queryParameterData) {
                $describedBy->addQueryParameter(
                    NamedParameter::createFromArray($key, $queryParameterData)
                );
            }
        }

        if (isset($data['responses']) && \is_array($data['responses'])) {
            foreach ($data['responses'] as $responseCode => $response) {
                $describedBy->addResponse(
                    Response::createFromArray($responseCode, $response ?: [])
                );
            }
        }

        return $describedBy;
    }
518281
protected function get($method, array $data = [], $key = 'key')
    {
        $data = $this->data($data);

        if (!isset($this->cache[$method][$key])) {
            $this->cache[$method][$key] = $this->client->$method($data);
        }

        return $this->cache[$method][$key];
    }