本文整理汇总了PHP中memcache_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_connect函数的具体用法?PHP memcache_connect怎么用?PHP memcache_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcache_connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: db_mysqli_query_fetch_list
function db_mysqli_query_fetch_list($mysqli, $query, $MYSQLI_TYPE)
{
$config = getConfig();
$params = $config['memcache'];
$memcache = memcache_connect($params['host'], $params['port']);
$memcacheQueryKey = 'QUERY' . $query['slow'];
$data = memcache_get($memcache, $memcacheQueryKey);
if (!empty($data)) {
} else {
if (!empty($query['fast'])) {
$result = mysqli_query($mysqli, $query['fast']);
} else {
$result = mysqli_query($mysqli, $query['slow']);
}
$data = [];
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$data[] = $row;
}
//another proc
/* $pid = pcntl_fork();
if ($pid == 0) {*/
memcache_set($memcache, $memcacheQueryKey, $data, 0, 60 * 10);
/* posix_kill(posix_getpid(), SIGTERM);
}*/
}
memcache_close($memcache);
return $data;
}
开发者ID:fedotovaleksandr,项目名称:vkTest,代码行数:28,代码来源:db_mysqli_query_fetch_list.php
示例2: ETCoreStart
/**
* 声明模板用法
*/
function ETCoreStart($set = array('ID' => '1', 'TplType' => 'htm', 'CacheDir' => 'cache', 'TemplateDir' => 'template', 'AutoImage' => 'on', 'LangDir' => 'language', 'Language' => 'default', 'Copyright' => 'off', 'MemCache' => ''))
{
$this->TplID = (defined('TemplateID') ? TemplateID : ((int) @$set['ID'] <= 1 ? 1 : (int) $set['ID'])) . '_';
$this->CacheDir = (defined('NewCache') ? NewCache : (trim($set['CacheDir']) != '' ? $set['CacheDir'] : 'cache')) . '/';
$this->TemplateDir = (defined('NewTemplate') ? NewTemplate : (trim($set['TemplateDir']) != '' ? $set['TemplateDir'] : 'template')) . '/';
$this->Ext = @$set['TplType'] != '' ? $set['TplType'] : 'htm';
$this->AutoImage = @$set['AutoImage'] == 'off' ? 0 : 1;
$this->Copyright = @$set['Copyright'] == 'off' ? 0 : 1;
$this->Server = is_array($GLOBALS['_SERVER']) ? $GLOBALS['_SERVER'] : $_SERVER;
$this->version = trim($_GET['EaseTemplateVer']) ? die('Ease Templae E3!') : '';
//载入语言文件
$this->LangDir = (defined('LangDir') ? LangDir : (@$set['LangDir'] != 'language' && @$set['LangDir'] ? $set['LangDir'] : 'language')) . '/';
if (is_dir($this->LangDir)) {
$this->Language = defined('Language') ? Language : ($set['Language'] != 'default' && $set['Language'] ? $set['Language'] : 'default');
if (@is_file($this->LangDir . $this->Language . '.php')) {
$lang = array();
@(include_once $this->LangDir . $this->Language . '.php');
$this->LangData = $lang;
}
} else {
$this->Language = 'default';
}
//缓存目录检测以及运行模式
if (@ereg(':', $set['MemCache'])) {
$this->RunType = 'MemCache';
$memset = explode(":", $set['MemCache']);
$this->Emc = memcache_connect($memset[0], $memset[1]) or die("Could not connect!");
} else {
$this->RunType = @substr(@sprintf('%o', @fileperms($this->CacheDir)), -3) == 777 && is_dir($this->CacheDir) ? 'Cache' : 'Replace';
}
$CompileBasic = array('/(\\{\\s*|<!--\\s*)inc_php:([a-zA-Z0-9_\\[\\]\\.\\,\\/\\?\\=\\#\\:\\;\\-\\|\\^]{5,200})(\\s*\\}|\\s*-->)/eis', '/<!--\\s*DEL\\s*-->/is', '/<!--\\s*IF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSEIF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSE\\s*-->/is', '/<!--\\s*END\\s*-->/is', '/<!--\\s*([a-zA-Z0-9_\\$\\[\\]\'\\"]{2,60})\\s*(AS|as)\\s*(.+?)\\s*-->/', '/<!--\\s*while\\:\\s*(.+?)\\s*-->/is', '/(\\{\\s*|<!--\\s*)lang\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)row\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)color\\:\\s*([\\#0-9A-Za-z]+\\,[\\#0-9A-Za-z]+)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)dir\\:([^\\{\\}]{1,100})(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)run\\:(\\}|\\s*-->)\\s*(.+?)\\s*(\\{|<!--\\s*)\\/run(\\s*\\}|\\s*-->)/is', '/(\\{\\s*|<!--\\s*)run\\:(.+?)(\\s*\\}|\\s*-->)/is', '/\\{([a-zA-Z0-9_\'\\"\\[\\]\\$]{1,100})\\}/');
$this->Compile = is_array($this->Compile) ? array_merge($this->Compile, $CompileBasic) : $CompileBasic;
$AnalysisBasic = array('$this->inc_php("\\2")', '";if($ET_Del==true){echo"', '";if(\\2){echo"', '";}elseif(\\2){echo"', '";}else{echo"', '";}echo"', '";\\$_i=0;foreach((array)\\1 AS \\3){\\$_i++;echo"', '";\\$_i=0;while(\\1){\\$_i++;echo"', '$this->lang("\\2")', '$this->Row("\\2")', '$this->Color("\\2")', '$this->Dirs("\\2")', '";\\3;echo"', '";\\2;echo"', '";echo \\$\\1;echo"');
$this->Analysis = is_array($this->Analysis) ? array_merge($this->Analysis, $AnalysisBasic) : $AnalysisBasic;
}
开发者ID:anLl,项目名称:Apply2,代码行数:38,代码来源:template.core.php
示例3: getUsage
public function getUsage()
{
if (!function_exists('memcache_get_extended_stats')) {
return false;
}
if ($this->usage === null) {
$servers = DebugBar::getConfig('memcached');
$server = array_shift($servers);
$memcache = memcache_connect($server['host'], $server['port']);
if ($memcache === false) {
return false;
}
foreach ($servers as $server) {
memcache_add_server($memcache, $server['host'], $server['port']);
}
$stats = memcache_get_extended_stats($memcache);
$memory_used = 0;
$memory_total = 0;
foreach ($stats as $host => $usage) {
$memory_used += $usage['bytes'];
$memory_total += $usage['limit_maxbytes'];
$this->usage[$host] = array('Version' => $usage['version'], 'Uptime' => $this->formatSeconds($usage['uptime']), 'Total memory' => $this->formatBytes($usage['limit_maxbytes']), 'Used memory' => $this->formatBytes($usage['bytes']), 'Available memory' => $this->formatBytes($usage['limit_maxbytes'] - $usage['bytes']), 'Threads / second' => $this->formatNum($usage['total_connections'] / $usage['uptime']), 'Current threads' => $usage['curr_connections'], 'Queries / second' => $this->formatNum($usage['cmd_get'] / $usage['uptime']), 'Hits' => $usage['get_hits'] . ' (' . $this->formatNum($usage['get_hits'] * 100 / $usage['cmd_get']) . '%)', 'Misses' => $usage['get_misses'] . ' (' . $this->formatNum($usage['get_misses'] * 100 / $usage['cmd_get']) . '%)', 'Inserts' => $usage['cmd_set'], 'Deletes' => $usage['delete_hits'], 'Items' => $usage['curr_items']);
}
$this->percent_used = $this->formatNum($memory_used * 100 / $memory_total);
}
return $this->usage;
}
开发者ID:rubn-g,项目名称:debugbar,代码行数:27,代码来源:MemcachedPanel.php
示例4: getFromMemcache
private static function getFromMemcache()
{
if (!XIIS_CACHE_MEMCACHE) {
return;
}
if (!empty(self::$_outputData)) {
return;
}
if (self::$_xiiCacheID == '') {
return;
}
$servers = Yii::$app->memcache->getServers();
$memcache = false;
foreach ($servers as $v) {
$readay = @memcache_connect($v->host, $v->port);
if ($readay) {
$memcache = true;
break;
}
}
XiiError::ignoreError();
if (!$memcache) {
self::logRecord([XIIS_DATA_FROM_MEMCACHE => self::FAIL_TO_CONNECT_MEMCACHE]);
} else {
$tmp = Yii::$app->memcache->get(self::$_xiiCacheID);
if ($tmp) {
self::$_outputData = XiiJson::decode($tmp);
self::$_dataFrom = XIIS_DATA_FROM_MEMCACHE;
self::logRecord([XIIS_DATA_FROM_MEMCACHE => self::SUCCESS_GET_FROM_MEMCACHE]);
} else {
self::logRecord([XIIS_DATA_FROM_MEMCACHE => self::FAIL_GET_FROM_MEMCACHE]);
}
}
}
开发者ID:keigonec,项目名称:XiiBackend,代码行数:34,代码来源:TraitData.php
示例5: __construct
public function __construct()
{
if (!function_exists("memcache_connect")) {
return;
}
$this->memcache = memcache_connect("127.0.0.1", 11211);
}
开发者ID:zarethernet,项目名称:yaamp,代码行数:7,代码来源:memcache.php
示例6: checkConnect
public static function checkConnect()
{
$test = @memcache_connect('127.0.0.1', 11211);
if ($test === false) {
throw new Exception('memcached is _probably_ not running');
}
}
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:7,代码来源:MemoryCache.php
示例7: process_request
function process_request()
{
$item_name = isset($_POST['item_name']) ? $_POST['item_name'] : null;
$item_price = isset($_POST['item_price']) ? $_POST['item_price'] : null;
$item_description = isset($_POST['item_description']) ? $_POST['item_description'] : null;
$item_img = isset($_POST['item_img']) ? $_POST['item_img'] : null;
if (is_null($item_name)) {
die;
} else {
$item_name = htmlspecialchars(trim($item_name));
if ($item_name === '') {
die;
}
}
if (is_null($item_price) || !preg_match("/^\\d+([.,]\\d{1,2})?\$/", $item_price)) {
die;
}
$item_price = str_replace(',', '.', $item_price);
if (is_null($item_description)) {
die;
} else {
$item_description = htmlspecialchars(trim($item_description));
}
if (is_null($item_img)) {
$item_img = "Null";
}
$id = db_insert_item($item_name, $item_description, $item_price, $item_img);
$mc_handler = memcache_connect('localhost');
if (memcache_get($mc_handler, 'total_rows') !== false) {
memcache_increment($mc_handler, 'total_rows');
pagination_rebuild_ids($mc_handler, $id);
pagination_rebuild_prices($mc_handler, $item_price);
}
header('Location: /view_item.php?id=' . $id);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:35,代码来源:create_item_tech.php
示例8: _connect
/**
* Connect to memcache server
*
* @access private
* @param array Connection information
* @return boolean Initiation successful
*/
private function _connect($server_info = array())
{
if (!count($server_info)) {
$this->crashed = true;
return false;
}
if (!isset($server_info['memcache_server_1']) or !isset($server_info['memcache_port_1'])) {
$this->crashed = true;
return false;
}
$this->link = memcache_connect($server_info['memcache_server_1'], $server_info['memcache_port_1']);
if (!$this->link) {
$this->crashed = true;
return false;
}
if (isset($server_info['memcache_server_2']) and isset($server_info['memcache_port_2'])) {
memcache_add_server($this->link, $server_info['memcache_server_2'], $server_info['memcache_port_2']);
}
if (isset($server_info['memcache_server_3']) and isset($server_info['memcache_port_3'])) {
memcache_add_server($this->link, $server_info['memcache_server_3'], $server_info['memcache_port_3']);
}
if (function_exists('memcache_set_compress_threshold')) {
memcache_set_compress_threshold($this->link, 20000, 0.2);
}
return true;
}
开发者ID:dalandis,项目名称:Visualization-of-Cell-Phone-Locations,代码行数:33,代码来源:classCacheMemcache.php
示例9: getMem
private function getMem()
{
if ($this->_mem == null) {
$this->_mem = memcache_connect(getC("MEMCACHE_SERVER"), getC("MEMCACHE_PORT"));
}
return $this->_mem;
}
开发者ID:lingPro,项目名称:zj_web_demo,代码行数:7,代码来源:MyCache.class.php
示例10: requeue_snapshot
public function requeue_snapshot()
{
ignore_user_abort(true);
header("Connection: Close");
flush();
ob_end_flush();
$m = memcache_connect('127.0.0.1', 11211);
$urlkey = sha1($this->snapshot_url);
if (isset($_GET['requeue']) && 'true' != $_GET['requeue']) {
if (memcache_get($m, $urlkey)) {
die;
}
}
memcache_set($m, $urlkey, 1, 0, 300);
$requeue_url = self::renderer . "/queue?url=" . rawurlencode($this->snapshot_url) . "&f=" . urlencode($this->snapshot_file);
$retval = file_get_contents($requeue_url);
$tries = 1;
while (false === $retval && $tries <= 5) {
sleep(1);
// in the event that the failed call is due to a mShots.js service restart,
// we need to be a little patient as the service comes back up
$retval = file_get_contents($requeue_url);
$tries++;
}
}
开发者ID:nexusthemes,项目名称:mShots,代码行数:25,代码来源:class-mshots.php
示例11: connect
/**
* 链接memcache,保存实例化的memcache
*/
private function connect()
{
if ($this->mem) {
return $this;
} else {
return $this->mem = memcache_connect($this->config['memcached_host'], $this->config['memcached_port']) or Debug::add('memcached连接失败');
}
}
开发者ID:pgfeng,项目名称:ssy.9icode.club,代码行数:11,代码来源:memcacheDriver.class.php
示例12: __construct
public function __construct()
{
$this->memcache = memcache_connect(Pluf::f('cache_memcached_server', 'localhost'), Pluf::f('cache_memcached_port', 11211));
if (false === $this->memcache) {
$this->memcache = null;
}
$this->keyprefix = Pluf::f('cache_memcached_keyprefix', '');
}
开发者ID:burbuja,项目名称:pluf,代码行数:8,代码来源:Memcached.php
示例13: setUp
public function setUp()
{
if ($this->mmcError) {
return;
}
$this->mmc = memcache_connect('localhost', 11211);
memcache_flush($this->mmc);
}
开发者ID:hadrienl,项目名称:jelix,代码行数:8,代码来源:jkvdb.memcache.html_cli.php
示例14: process_request
function process_request()
{
$item_id = isset($_POST['item_id']) ? intval($_POST['item_id']) : null;
$item_name = isset($_POST['item_name']) ? $_POST['item_name'] : null;
$item_price = isset($_POST['item_price']) ? $_POST['item_price'] : null;
$item_description = isset($_POST['item_description']) ? $_POST['item_description'] : null;
$item_img = isset($_POST['item_img']) ? $_POST['item_img'] : null;
if (is_null($item_id) || $item_id <= 0) {
die;
}
if (!is_null($item_name)) {
$item_name = htmlspecialchars(trim($item_name));
if ($item_name === '') {
die;
}
}
if (!is_null($item_price)) {
if (!preg_match("/^\\d+([.,]\\d{1,2})?\$/", $item_price)) {
die;
}
}
if (!is_null($item_description)) {
$item_description = htmlspecialchars(trim($item_description));
}
$item = db_get_item($item_id);
if (!$item) {
die;
}
$values = [];
if (!is_null($item_name)) {
$values['name'] = $item_name;
}
if (!is_null($item_price)) {
$item_price = str_replace(',', '.', $item_price);
$values['price'] = $item_price;
}
if (!is_null($item_description)) {
$values['description'] = $item_description;
}
if (!is_null($item_img)) {
$values['imgurl'] = $item_img;
}
if (!empty($values)) {
db_update_item($item_id, $values);
$mc_handler = memcache_connect('localhost');
memcache_delete($mc_handler, get_page_cache_key($item_id));
$min_price = min($item_price, $item['price']);
pagination_rebuild_ids($mc_handler, $item_id, 1);
if ($item_price == $item['price']) {
$edited_pages_amount = 1;
} else {
$edited_pages_amount = 0;
}
pagination_rebuild_prices($mc_handler, $min_price, $edited_pages_amount);
pagination_rebuild_prices($mc_handler, $min_price);
}
header('Location: /view_item.php?id=' . $item_id);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:58,代码来源:edit_item_tech.php
示例15: __construct
function __construct($config = array())
{
parent::__construct($config);
if (defined('IS_SAE')) {
$this->_mamcache = memcache_init() or trigger_error('Memcache Init Error', E_USER_ERROR);
} else {
$this->_mamcache = memcache_connect($this->host, $this->port) or trigger_error('Memcache Connect Error', E_USER_ERROR);
}
}
开发者ID:cos800,项目名称:tmdphp,代码行数:9,代码来源:memcache.php
示例16: __construct
public function __construct($sServer = '127.0.0.1', $nPort = 11211)
{
if (!function_exists('memcache_connect')) {
throw new \Exception('not fount memcache functions .');
}
if (!($this->hMemcacheConnection = memcache_connect($sServer, $nPort))) {
throw new \Exception('can not connect memcache server: ' . $sServer . ':' . $nPort);
}
}
开发者ID:JeCat,项目名称:framework,代码行数:9,代码来源:Memcache.php
示例17: __construct
public function __construct()
{
if (!function_exists('memcache_connect')) {
FeiError('PHP环境未安装Memcache函数库!');
}
$params = spExt('FeiAccessCache');
$memcache_host = isset($params['memcache_host']) ? $params['memcache_host'] : 'localhost';
$memcache_port = isset($params['memcache_port']) ? $params['memcache_port'] : '11211';
$this->mmc = memcache_connect($memcache_host, $memcache_port);
}
开发者ID:ivanberry,项目名称:grw,代码行数:10,代码来源:FeiAccessCache.php
示例18: __construct
public function __construct($options = [])
{
foreach ($options as $k => $v) {
if (property_exists($this, $k)) {
if (gettype($v) === gettype($this->{$k})) {
$this->{$k} = $v;
}
}
}
$this->connect = memcache_connect($this->host, $this->port);
$this->clearExpire();
}
开发者ID:schoolphp,项目名称:library,代码行数:12,代码来源:Memcache.php
示例19: connect
public static function connect()
{
if (self::$config_setup === FALSE) {
self::$host = Kohana::config('memcached.host');
self::$port = Kohana::config('memcached.port');
self::$set_flag = Kohana::config('memcached.set_flag');
self::$set_expire = Kohana::config('memcached.set_expire');
self::$delete_timeout = Kohana::config('memcached.delete_timeout');
self::$config_setup = TRUE;
}
return memcache_connect(self::$host, self::$port);
}
开发者ID:uxturtle,项目名称:core-module,代码行数:12,代码来源:memcached.php
示例20: __construct
/**
* MemcacheProvider constructor
* @param string $host
* @param number $port
* @throws \RuntimeException
*/
public function __construct($host = 'localhost', $port = 11211)
{
//check if memcache is available
if (!class_exists('\\Memcache')) {
throw new \RuntimeException("Memcache extension was not found on this server");
}
//connnect to Memcache server
$this->memcache = @memcache_connect($host, $port);
if ($this->memcache === false) {
throw new \RuntimeException("Connection to memcache server on '" . $host . "' (" . $port . ") failed");
}
}
开发者ID:emaphp,项目名称:simplecache,代码行数:18,代码来源:MemcacheProvider.php
注:本文中的memcache_connect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论