本文整理汇总了PHP中Memcache::host方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::host方法的具体用法?PHP Memcache::host怎么用?PHP Memcache::host使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::host方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: User
<?php
require '../core/model.php';
require '../libraries/debug.php';
require '../libraries/config.php';
require '../libraries/memcache.php';
require '../libraries/database.php';
require '../config/global.php';
require '../models/user.php';
//Debug::hide_level(DEBUG_TRACE);
Memcache::$host = Config::get('memcache_host');
Database::connect(Config::get('db_host'), Config::get('db_user'), Config::get('db_pass'), Config::get('db_database'));
Database::query("delete from users");
$u = new User();
$u->email_address = 'brian@systempoint.us';
$u->password = md5('doh');
$u->save();
$new_id = $u->getKeyValue();
$u2 = new User($new_id);
print_r($u2);
示例2: microtime
<?php
require '../libraries/debug.php';
require '../libraries/memcache.php';
Debug::hide_level(DEBUG_TRACE);
Memcache::$host = '10.0.0.5';
$tmp_movie = '2001: A Space Odyssey';
$iterations = 1000;
$set_times = 0;
$get_times = 0;
for ($i = 0; $i < $iterations; $i++) {
$key = 'movie_' . $i;
$ts_start = microtime(true);
Memcache::set($key, $tmp_movie);
$ts_end = microtime(true);
$set_times += $ts_end - $ts_start;
$ts_start = microtime(true);
$movie = Memcache::get($key);
$ts_end = microtime(true);
$get_times += $ts_end - $ts_start;
}
$set_avg = $set_times / $iterations;
$get_avg = $get_times / $iterations;
Debug::infof('SET operations took an average of %0.5f seconds', $set_avg);
Debug::infof('GET operations took an average of %0.5f seconds', $get_avg);
Debug::infof('Movie name is %s', $movie);
/**
* Desired output:
*
* [INFO] SET operations took an average of 0.00016 seconds
* [INFO] GET operations took an average of 0.00022 seconds