private function getCacheKey(?string $format, array $context)
    {
        foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
            unset($context[$key]);
        }
        unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
        unset($context['cache_key']); // avoid artificially different keys

        try {
            return md5($format.serialize([
                'context' => $context,
                'ignored' => $this->ignoredAttributes,
                'camelized' => $this->camelizedAttributes,
            ]));
        } catch (\Exception $exception) {
            // The context cannot be serialized, skip the cache
            return false;
        }
    }
private function getCacheKey(?string $format, array $context)
    {
        foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
            unset($context[$key]);
        }
        unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
        unset($context['cache_key']); // avoid artificially different keys

        try {
            return md5($format.serialize([
                'context' => $context,
                'ignored' => $this->ignoredAttributes,
                'camelized' => $this->camelizedAttributes,
            ]));
        } catch (\Exception $exception) {
            // The context cannot be serialized, skip the cache
            return false;
        }
    }
private function getCacheKey ( ? string $ format , array $ context ) { foreach ( $ context [ self :: EXCLUDE_FROM_CACHE_KEY ] ?? $ this -> defaultContext [ self :: EXCLUDE_FROM_CACHE_KEY ] as $ key ) { unset ( $ context [ $ key ] ) ; } unset ( $ context [ self :: EXCLUDE_FROM_CACHE_KEY ] ) ; unset ( $ context [ 'cache_key' ] ) ; // avoid artificially different keys try { return md5 ( $ format . serialize ( [ 'context' => $ context , 'ignored' => $ this -> ignoredAttributes , 'camelized' => $ this -> camelizedAttributes , ] ) ) ; } catch ( \ Exception $ exception ) { // The context cannot be serialized, skip the cache return false ; } }
Builds the cache key for the attributes cache.

The key must be different for every option in the context that could change which attributes should be handled.

@return bool|string
Builds the cache key for the attributes cache .