function oembed_cache_key in oEmbed 7
Helper function generates a cache key based on url and request parameters.
Parameters
$url:
array $parameters:
Return value
string
1 call to oembed_cache_key()
- oembed_oembed_fetch in ./
oembed.module - oEmbed fetcher and parser.
File
- ./
oembed.module, line 260 - Core functionality for oEmbed
Code
function oembed_cache_key($url, $parameters = array()) {
$cache_keys = array();
// Remove trailing slash to normalize URLs.
$cache_keys[] = hash('sha256', substr($url, -1) == '/' ? substr($url, 0, -1) : $url);
// Hash and serialize request parameters and display options.
if (!empty($parameters)) {
// Normalize the parameters and attributes for better cache performance.
ksort($parameters);
$parameters = array_filter($parameters);
$cache_keys[] = hash('sha256', serialize($parameters));
}
$cache_key = implode(':', $cache_keys);
return $cache_key;
}