Exemplo n.º 1
0
                // get contents of output buffer
                $html = ob_get_contents();
                // clean output buffer
                ob_end_clean();
                echo $html;
                // store html contents to redis cache
                $redis->hset($dkey, $ukey, $html);
                $msg = 'cache is set';
            }
        }
    }
}
$end = microtime();
// get end execution time
// show messages if debug is enabled
if ($debug) {
    echo $msg . ': ';
    echo t_exec($start, $end);
}
// time diff
function t_exec($start, $end)
{
    $t = getmicrotime($end) - getmicrotime($start);
    return round($t, 5);
}
// get time
function getmicrotime($t)
{
    list($usec, $sec) = explode(" ", $t);
    return (double) $usec + (double) $sec;
}
Exemplo n.º 2
0
                // store html contents to redis cache
                $redis->hset($dkey, $ukey, $html);
                $msg = 'cache is set';
            }
        }
    }
}
$end = microtime();
// get end execution time
// show messages if debug is enabled
if ($debug) {
    echo $msg . ': ';
    echo t_exec($start, $end);
}
if ($cached && $display_powered_by_redis) {
    // You should move this CSS to your CSS file and change the: float:right;margin:20px 0;
    echo "<style>#redis_powered{float:right;margin:20px 0;background:url(http://images.staticjw.com/jim/3959/redis.png) 10px no-repeat #fff;border:1px solid #D7D8DF;padding:10px;width:190px;}\n\t#redis_powered div{width:190px;text-align:right;font:10px/11px arial,sans-serif;color:#000;}</style>";
    echo "<a href=\"http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/\" style=\"text-decoration:none;\"><div id=\"redis_powered\"><div>Page generated in<br/> " . t_exec($start, $end) . " sec</div></div></a>";
}
// time diff
function t_exec($start, $end)
{
    $t = getmicrotime($end) - getmicrotime($start);
    return round($t, 5);
}
// get time
function getmicrotime($t)
{
    list($usec, $sec) = explode(" ", $t);
    return (double) $usec + (double) $sec;
}