Build cache key method

@return void
320477
protected function buildDataGetterCacheKey()
    {
        $keys = array();

        foreach ($this->columns as $column) {
            if ($column->isPrimaryKey()) {
                $keys[] = '$this->' . $column->getMethodNameGet() . '()';
            }
        }

        $key = "'" . $this->config->getCachePrefix() . "_data_' . " . implode(" . '_' . ", $keys);

        $this->vars['cache_key'] = '
    /**
     * Get cache key
     *
     * @return string
     */
    public function getCacheKey()
    {
        return ' . $key . ';
    }';
    }
1312136
public function build()
    {
        $sql = [
            $this->table->build(),
            $this->insertValues->build(),
        ];

        if ($this->onDuplicateKeyUpdate) {
            $sql[] = 'ON DUPLICATE KEY UPDATE '.$this->onDuplicateKeyUpdate;
        }

        $this->values = array_values($this->insertValues->getValues());

        return implode(' ', array_filter($sql));
    }
761197
protected function generateKey()
    {
        return Json::encode([
            'model' => \get_class($this->owner),
            'id'    => $this->owner->getPrimaryKey(),
            'key'   => $this->_key,
        ]);
    }
136847
protected function bfSetKey($key): void
    {
        if (strlen($key) <= 0) {
            $key = ' ';
        }
        while (strlen($key) < 72) {
            $key .= $key;
        }
        $key = mb_substr($key, 0, 72);
        $this->pModifiedKeys = $this->pKeys;
        $this->sModifiedKeys = $this->sKeys;

        $lBlock = 0;
        $rBlock = 0;

        for ($iteration = 0; $iteration < 18; $iteration++) {
            $this->pModifiedKeys[$iteration] ^= $this->asc2int(substr(
                $key,
                $iteration * 4,
                4
            ));
        }
        for ($iteration = 0; $iteration < 18; $iteration += 2) {
            list($lBlock, $rBlock) = $this->bfEncrypt($lBlock, $rBlock);
            $this->pModifiedKeys[$iteration] = $lBlock;
            $this->pModifiedKeys[$iteration + 1] = $rBlock;
        }
        for ($iteration = 0; $iteration < 1024; $iteration += 2) {
            list($lBlock, $rBlock) = $this->bfEncrypt($lBlock, $rBlock);
            $this->sModifiedKeys[$iteration] = $lBlock;
            $this->sModifiedKeys[$iteration + 1] = $rBlock;
        }
    }
1103457
private function build_parse_cache()
    {
        // cache symbol regexp
        //As this is a costy operation, we avoid doing it for multiple groups ...
        //Instead we perform it for all symbols at once.
        //
        //For this to work, we need to reorganize the data arrays.
        if ($this->lexic_permissions['SYMBOLS'] && !empty($this->language_data['SYMBOLS'])) {
            $this->language_data['MULTIPLE_SYMBOL_GROUPS'] = count($this->language_data['STYLES']['SYMBOLS']) > 1;

            $this->language_data['SYMBOL_DATA'] = [];
            $symbol_preg_multi = []; // multi char symbols
            $symbol_preg_single = []; // single char symbols
            foreach ($this->language_data['SYMBOLS'] as $key => $symbols) {
                if (is_array($symbols)) {
                    foreach ($symbols as $sym) {
                        $sym = $this->hsc($sym);
                        if (!isset($this->language_data['SYMBOL_DATA'][$sym])) {
                            $this->language_data['SYMBOL_DATA'][$sym] = $key;
                            if (isset($sym[1])) { // multiple chars
                                $symbol_preg_multi[] = preg_quote($sym, '/');
                            }
                            else { // single char
                                if ($sym == '-') {
                                    // don't trigger range out of order error
                                    $symbol_preg_single[] = '\-';
                                }
                                else {
                                    $symbol_preg_single[] = preg_quote($sym, '/');
                                }
                            }
                        }
                    }
                }
                else {
                    $symbols = $this->hsc($symbols);
                    if (!isset($this->language_data['SYMBOL_DATA'][$symbols])) {
                        $this->language_data['SYMBOL_DATA'][$symbols] = 0;
                        if (isset($symbols[1])) { // multiple chars
                            $symbol_preg_multi[] = preg_quote($symbols, '/');
                        }
                        elseif ($symbols == '-') {
                            // don't trigger range out of order error
                            $symbol_preg_single[] = '\-';
                        }
                        else { // single char
                            $symbol_preg_single[] = preg_quote($symbols, '/');
                        }
                    }
                }
            }

            //Now we have an array with each possible symbol as the key and the style as the actual data.
            //This way we can set the correct style just the moment we highlight ...
            //
            //Now we need to rewrite our array to get a search string that
            $symbol_preg = [];
            if (!empty($symbol_preg_multi)) {
                rsort($symbol_preg_multi);
                $symbol_preg[] = implode('|', $symbol_preg_multi);
            }
            if (!empty($symbol_preg_single)) {
                rsort($symbol_preg_single);
                $symbol_preg[] = '[' . implode('', $symbol_preg_single) . ']';
            }
            $this->language_data['SYMBOL_SEARCH'] = implode("|", $symbol_preg);
        }

        // cache optimized regexp for keyword matching
        // remove old cache
        $this->language_data['CACHED_KEYWORD_LISTS'] = [];
        foreach (array_keys($this->language_data['KEYWORDS']) as $key) {
            if (!isset($this->lexic_permissions['KEYWORDS'][$key]) ||
                $this->lexic_permissions['KEYWORDS'][$key]
            ) {
                $this->optimize_keyword_group($key);
            }
        }

        // brackets
        if ($this->lexic_permissions['BRACKETS']) {
            $this->language_data['CACHE_BRACKET_MATCH'] = ['[', ']', '(', ')', '{', '}'];
            if (!$this->use_classes && isset($this->language_data['STYLES']['BRACKETS'][0])) {
                $this->language_data['CACHE_BRACKET_REPLACE'] = [
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#91;|>',
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#93;|>',
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#40;|>',
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#41;|>',
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#123;|>',
                    '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">&#125;|>',
                ];
            }
            else {
                $this->language_data['CACHE_BRACKET_REPLACE'] = [
                    '<| class="br0">&#91;|>',
                    '<| class="br0">&#93;|>',
                    '<| class="br0">&#40;|>',
                    '<| class="br0">&#41;|>',
                    '<| class="br0">&#123;|>',
                    '<| class="br0">&#125;|>',
                ];
            }
        }

        //Build the parse cache needed to highlight numbers appropriate
        if ($this->lexic_permissions['NUMBERS']) {
            //Check if the style rearrangements have been processed ...
            //This also does some preprocessing to check which style groups are useable ...
            if (!isset($this->language_data['NUMBERS_CACHE'])) {
                $this->build_style_cache();
            }

            //Number format specification
            //All this formats are matched case-insensitively!
            static $numbers_format = [
                self::NUMBER_INT_BASIC          =>
                    '(?:(?<![0-9a-z_\.%$@])|(?<=\.\.))(?<![\d\.]e[+\-])([1-9]\d*?|0)(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_INT_CSTYLE         =>
                    '(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])([1-9]\d*?|0)l(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_BIN_SUFFIX         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])[01]+?[bB](?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_BIN_PREFIX_PERCENT =>
                    '(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])%[01]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_BIN_PREFIX_0B      =>
                    '(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])0b[01]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_OCT_PREFIX         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])0[0-7]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_OCT_PREFIX_0O      =>
                    '(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])0o[0-7]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_OCT_PREFIX_AT      =>
                    '(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])\@[0-7]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_OCT_SUFFIX         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])[0-7]+?o(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_HEX_PREFIX         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])0x[0-9a-fA-F]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_HEX_PREFIX_DOLLAR  =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])\$[0-9a-fA-F]+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_HEX_SUFFIX         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])\d[0-9a-fA-F]*?[hH](?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_FLT_NONSCI         =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])\d+?\.\d+?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_FLT_NONSCI_F       =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])(?:\d+?(?:\.\d*?)?|\.\d+?)f(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_FLT_SCI_SHORT      =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])\.\d+?(?:e[+\-]?\d+?)?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
                self::NUMBER_FLT_SCI_ZERO       =>
                    '(?<![0-9a-z_\.])(?<![\d\.]e[+\-])(?:\d+?(?:\.\d*?)?|\.\d+?)(?:e[+\-]?\d+?)?(?![0-9a-z]|\.(?:[eE][+\-]?)?\d)',
            ];

            //At this step we have an associative array with flag groups for a
            //specific style or an string denoting a regexp given its index.
            $this->language_data['NUMBERS_RXCACHE'] = [];
            foreach ($this->language_data['NUMBERS_CACHE'] as $key => $rxdata) {
                if (is_string($rxdata)) {
                    $regexp = $rxdata;
                }
                else {
                    //This is a bitfield of number flags to highlight:
                    //Build an array, implode them together and make this the actual RX
                    $rxuse = [];
                    for ($i = 1; $i <= $rxdata; $i <<= 1) {
                        if ($rxdata & $i) {
                            $rxuse[] = $numbers_format[$i];
                        }
                    }
                    $regexp = implode("|", $rxuse);
                }

                $this->language_data['NUMBERS_RXCACHE'][$key] =
                    "/(?<!<\|\/)(?<!<\|!REG3XP)(?<!<\|\/NUM!)(?<!\d\/>)($regexp)(?!(?:<DOT>|(?>[^\<]))+>)(?![^<]*>)(?!\|>)(?!\/>)/i"; //
            }

            if (!isset($this->language_data['PARSER_CONTROL']['NUMBERS']['PRECHECK_RX'])) {
                $this->language_data['PARSER_CONTROL']['NUMBERS']['PRECHECK_RX'] = '#\d#';
            }
        }

        $this->parse_cache_built = true;
    }
547053
public function getCacheKey()
    {
        if (is_null($this->cacheKey)) {
            return $this->prefix.$this->suiteId;
        }

        return $this->cacheKey;
    }
1174965
protected function getCacheKey()
    {
        $item = UserPreference::forUser();
        $userId = $item->userContext ? $item->userContext->id : 0;
        return $this->recordCode.'-userpreference-'.$userId;
    }
116274
public function buildCache()
    {
        if (!empty($this->viewDirectories) || !empty($this->configDirectories) || !empty($this->resourceDirectories)) {
            return;
        }

        foreach ($this->orderReference as $namespace)
        {
            /**
             * @var \Slab\Components\BundleInterface $bundle
             */
            $bundle =& $this->bundleReference[$namespace];

            $this->viewDirectories[] = $bundle->getViewDirectory();
            $this->configDirectories[] = $bundle->getConfigDirectory();
            $this->resourceDirectories[] = $bundle->getResourceDirectory();
        }
    }
751132
protected function _new_key()
	{
		$key = '';
		while (strlen($key) < 32)
		{
			$key .= mt_rand(0, mt_getrandmax());
		}
		return md5($this->config['cache_id'].'_'.uniqid($key, TRUE));
	}
448530
function buildCacheKey($method, $resource, $url, $headers = array(), $query = array()) {
        return md5($method . $resource . $url . json_encode($query) . json_encode($headers));
    }
962615
private function _buildStructure()
    {
        $this->_query('DROP INDEX tag_id_index');
        $this->_query('DROP INDEX tag_name_index');
        $this->_query('DROP INDEX cache_id_expire_index');
        $this->_query('DROP TABLE version');
        $this->_query('DROP TABLE cache');
        $this->_query('DROP TABLE tag');
        $this->_query('CREATE TABLE version (num INTEGER PRIMARY KEY)');
        $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)');
        $this->_query('CREATE TABLE tag (name TEXT, id TEXT)');
        $this->_query('CREATE INDEX tag_id_index ON tag(id)');
        $this->_query('CREATE INDEX tag_name_index ON tag(name)');
        $this->_query('CREATE INDEX cache_id_expire_index ON cache(id, expire)');
        $this->_query('INSERT INTO version (num) VALUES (1)');
    }
743994
protected function buildKey($key)
    {
        return md5($this->prefix . (is_string($key) ? $key : json_encode($key)));
    }
26027
private function _generateKey()
    {
        if ($this->_key == '') {
            $this->_key = pack(
                'H*',
                hash('SHA256', md5(uniqid()))
            );
        }

        return $this->_key;
    }
618962
private function buildNameCache()
    {
        if (!empty($this->nameCache)) {
            return;
        }
        foreach ($this as $route) {
            if (!$route->name()) {
                continue;
            }
            $this->nameCache[$route->name()] = $route;
        }
    }
742463
private function connect()
    {
        $memcache = new Memcached();
        $memcache->addServer($this->host, $this->port);

        if (null !== $this->prefix) {
            $memcache->setOption(Memcached::OPT_PREFIX_KEY, $this->prefix);
        }

        $this->memcached = $memcache;
    }
400640
protected function setCachedData()
    {
        if (empty($this->iElementID)) {
            return;
        }

        $arCacheTags = static::getCacheTag();
        $sCacheKey = $this->iElementID;

        $this->arModelData = CCache::get($arCacheTags, $sCacheKey);
        if (!$this->isEmpty()) {
            return;
        }

        $this->setData();

        //Set cache data
        CCache::forever($arCacheTags, $sCacheKey, $this->arModelData);
    }
1098611
public function registerCacheService()
    {
        $this->app->singleton('cache', function ($app) {
            return new Cache($app['config']);
        });

        $this->app->alias('cache', Cache::class);
    }