function search_results_from_cache($query, $source, $type, $license, $count)
{
    global $redis;
    $identifier = identifier_for_query($query, $source, $type, $license);
    $result = false;
    $text = $redis->get($identifier);
    return json_decode($text, true);
}
function fetch_results_maybe_cached($query, $source, $type, $license, $count, $fetch_results)
{
    $foo = search_results_from_cache($query, $source, $type, $license, $count);
    if ($foo) {
        $was_cached = true;
    } else {
        $foo = $fetch_results($query, $source, $type, $license, $count);
        cache_search_results($foo, $query, $source, $type, $license, $count);
        $was_cached = false;
    }
    $identifier = identifier_for_query($query, $source, $type, $license);
    return new SearchResults($foo, $source, $identifier, $was_cached, CACHE_IMPLEMENTATION);
}