framework/caching/Cache.php
public function buildKey($key)
    {
        if (is_string($key)) {
            $key = ctype_alnum($key) && StringHelper::byteLength($key) <= 32 ? $key : md5($key);
        } else {
            if ($this->_igbinaryAvailable) {
                $serializedKey = igbinary_serialize($key);
            } else {
                $serializedKey = serialize($key);
            }

            $key = md5($serializedKey);
        }

        return $this->keyPrefix . $key;
    }
public function buildKey($key)
    {
        if (is_string($key)) {
            $key = ctype_alnum($key) && StringHelper::byteLength($key) <= 32 ? $key : md5($key);
        } else {
            if ($this->_igbinaryAvailable) {
                $serializedKey = igbinary_serialize($key);
            } else {
                $serializedKey = serialize($key);
            }

            $key = md5($serializedKey);
        }

        return $this->keyPrefix . $key;
    }
Builds a normalized cache key from a given key.

If the given key is a string containing alphanumeric characters only and no more than 32 characters,
then the key will be returned back prefixed with [[keyPrefix]]. Otherwise, a normalized key
is generated by serializing the given key, applying MD5 hashing, and prefixing with [[keyPrefix]].

@param mixed $key the key to be normalized
@return string the generated cache key