Hashes a descriptive key to make it shorter and still unique.
@param string|int $key
@param cache_definition $definition
@return string
198290
public static function hash_key($key, cache_definition $definition) {
        if ($definition->uses_simple_keys()) {
            if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
                throw new coding_exception('Cache definition '.$definition->get_id().' requires simple keys. Invalid key provided.', $key);
            }
            // We put the key first so that we can be sure the start of the key changes.
            return (string)$key . '-' . $definition->generate_single_key_prefix();
        }
        $key = $definition->generate_single_key_prefix() . '-' . $key;
        return sha1($key);
    }
1035115
protected function _convertKeyNames($key)
    {
        if (array_key_exists($key, self::$_cacheKeys)) {
            return self::$_cacheKeys[$key];
        }

        $convertedKey = strtolower(
            preg_replace('/(.)([A-Z0-9])/', "$1_$2", $key)
        );
        self::$_cacheKeys[$key] = $convertedKey;
        return $convertedKey;
    }
566246
protected function checkKey($key):string{

		if(!is_string($key) || empty($key)){
			$msg = 'invalid cache key: "'.$key.'"';
			$this->logger->error($msg);

			throw new InvalidArgumentException($msg);
		}

		return $key;
	}
1065700
public function cacheTableDefinition($table, $definition, $which_connection='')
    {
        if ($which_connection == '') {
            $which_connection=$this->default_db;
        }
        if (!isset($this->structure_cache[$which_connection])) {
            $this->structure_cache[$which_connection] = array();
        }
        $this->structure_cache[$which_connection][$table] = $definition;

        return true;
    }
469543
protected function prettyHeaderKey(string $key) : string
    {
        return strtr(ucwords(strtr(strtr(strtolower($key), "_", " "), "-", " ")), " ", "-");
    }
1170055
static function storeCache( $key )
    {
        $translationCache = eZTranslationCache::cacheTable();
        if ( !isset( $translationCache[$key] ) )
        {
            eZDebug::writeWarning( "Translation cache for key '$key' does not exist, cannot store cache", __METHOD__ );
            return;
        }
        $internalCharset = eZTextCodec::internalCharset();
//         $cacheFileKey = "$key-$internalCharset";
        $cacheFileKey = $key;
        $cacheFileName = md5( $cacheFileKey ) . '.php';

        $cache =& $translationCache[$key];

        if ( !file_exists( eZTranslationCache::cacheDirectory() ) )
        {
            eZDir::mkdir( eZTranslationCache::cacheDirectory(), false, true );
        }
        $php = new eZPHPCreator( eZTranslationCache::cacheDirectory(), $cacheFileName );
        $php->addRawVariable( 'eZTranslationCacheCodeDate', self::CODE_DATE );
        $php->addSpace();
        $php->addRawVariable( 'CacheInfo', array( 'charset' => $internalCharset ) );
        $php->addRawVariable( 'TranslationInfo', $cache['info'] );
        $php->addSpace();
        $php->addRawVariable( 'TranslationRoot', $cache['root'] );
        $php->store( true );
    }
1168722
private function write_definitions_to_cache(array $definitions) {

        // Preserve the selected sharing option when updating the definitions.
        // This is set by the user and should never come from caches.php.
        foreach ($definitions as $key => $definition) {
            unset($definitions[$key]['selectedsharingoption']);
            unset($definitions[$key]['userinputsharingkey']);
            if (isset($this->configdefinitions[$key]) && isset($this->configdefinitions[$key]['selectedsharingoption'])) {
                $definitions[$key]['selectedsharingoption'] = $this->configdefinitions[$key]['selectedsharingoption'];
            }
            if (isset($this->configdefinitions[$key]) && isset($this->configdefinitions[$key]['userinputsharingkey'])) {
                $definitions[$key]['userinputsharingkey'] = $this->configdefinitions[$key]['userinputsharingkey'];
            }
        }

        $this->configdefinitions = $definitions;
        foreach ($this->configdefinitionmappings as $key => $mapping) {
            if (!array_key_exists($mapping['definition'], $definitions)) {
                unset($this->configdefinitionmappings[$key]);
            }
        }
        $this->config_save();
    }
564855
private function getFileName($key) {
		$key = str_replace(' ', '', $key);
		$cacheDir = rtrim($this->cachePath, '\\/') . '/';
		if ($this->directoryLevel > 0) {
			$hash = abs(crc32($key));
			$cacheDir .= $hash % 1024;
			for($i = 1; $i < $this->directoryLevel; ++$i) {
				if (($prefix = substr($hash, $i, 2)) !== false) {
					$cacheDir .= '/' . $prefix;
				}
			}
		}
		return $cacheDir . '/' . md5($key) . $this->cacheExt;
	}
793314
private function getFilenameFromCacheKey($key)
    {
        return $this->cacheDir
        . DIRECTORY_SEPARATOR
        . $this->getDirectoryHash($key)
        . DIRECTORY_SEPARATOR
        . $key
        . self::CACHE_FILE_SUFFIX;
    }
873738
protected function cacheKey(string $key_part): string
    {
        $key = md5('resolveAllUrls'.$key_part.self::SCHEMA_VERSION);

        return $key;
    }
712758
public function getFromCache($key)
  {
    $file = $this->cachePath . $this->getEncodedKey($key);
    if (file_exists($file)) {
      return unserialize(file_get_contents($file));
    }
    return null;
  }
520517
public function get_hash($key = 0)
	{
		$hashes = $this->get_hashes();
		if (isset($hashes[$key]))
		{
			return $hashes[$key];
		}

		return null;
	}
1192777
protected function deriveKey(string $key, string $salt, int $keySize): string
	{
		return hash_pbkdf2(static::DERIVATION_HASH, $key, $salt, static::DERIVATION_ITERATIONS, $keySize, true);
	}
770406
public function initialise(cache_definition $definition) {
        if ($this->is_initialised()) {
            throw new coding_exception('This memcached instance has already been initialised.');
        }
        $this->definition = $definition;
        $this->isinitialised = true;
    }
725250
protected function hashKey($key)
    {
        if ($key instanceof \DateTime) {
            return md5('_' . $key->format('c'));
        } elseif (is_object($key)) {
            return spl_object_hash($key);
        } elseif (false === $key) {
            return md5('_false');
        } elseif (true === $key) {
            return md5('_true');
        } elseif (null === $key) {
            return md5('_null');
        } elseif (is_array($key)) {
            array_multisort($key);
            return md5(json_encode($key));
        } elseif (is_int($key)) {
            return md5('_' . $key);
        } elseif (is_float($key)) {
            return md5('_' . $key);
        } else {
            return md5(strval($key));
        }
    }
1004833
function defineKey(value, key, src, propHash){
  var isDescriptor = descriptors.isDescriptor(value)
    , isRequired   = descriptors.isRequired(value)
    , prev;

  if (isRequired && (key in src)) return

  if ( !isRequired ) {
    if ( isDescriptor) {
      prev = (propHash.hasOwnProperty(key) ? propHash[key] : []).splice(0)
      return defineKey(value.resolve.call(src, key, prev), key, src, propHash)
    }
    else
      add(propHash, key, value)
  }

  src[key] = value
}
220583
public function hash($key)
    {
        $needle = hexdec(substr(md5($key), 0, 7));
        $server = $min = 0;
        $max = count($this->nodes) - 1;
        while ($max >= $min) {
            $position = (int) (($min + $max) / 2);
            $server = $this->nodes[$position];
            if ($needle < $server) {
                $max = $position - 1;
            } elseif ($needle > $server) {
                $min = $position + 1;
            } else {
                break;
            }
        }
        return $this->ring[$server];
    }