本文整理汇总了PHP中memcache_close函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_close函数的具体用法?PHP memcache_close怎么用?PHP memcache_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcache_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: __destruct
public function __destruct()
{
// if we were connected, close the connection again
if (is_resource($this->connection)) {
memcache_close($this->connection);
}
}
示例3: disconnect
static function disconnect()
{
if (CGlobal::$memcache_connect_id) {
memcache_close(CGlobal::$memcache_connect_id);
}
return TRUE;
}
示例4: cache_delete
function cache_delete($key, $timeout = 0)
{
$connection = cache_connect();
$res = memcache_delete($connection, (string) $key, (int) $timeout);
memcache_close($connection);
return $res;
}
示例5: tearDown
public function tearDown()
{
if ($this->mmcError) {
return;
}
memcache_close($this->mmc);
$this->mmc = null;
}
示例6: setUp
public function setUp()
{
if ($this->mmcError) {
return;
}
if (isset($this->conf['servers'])) {
list($this->mmhost, $this->mmport) = explode(":", $this->conf['servers']);
}
$mmc = memcache_connect($this->mmhost, (int) $this->mmport);
memcache_flush($mmc);
memcache_close($mmc);
}
示例7: changeCountItemsById
function changeCountItemsById($id, $val)
{
$config = getConfig();
$params = $config['memcache'];
$table = ['name' => 'item', 'dbname' => 'db_vktest', 'as' => 'i'];
$mysqli = db_mysqli_connect($table['dbname']);
$queryUpdate = 'UPDATE store SET countitems = countitems + ' . intval($val) . ' WHERE idstore = ' . intval($id);
$resultUpdate = mysqli_query($mysqli, $queryUpdate);
db_mysqli_close($mysqli);
$memcache = memcache_connect($params['host'], $params['port']);
memcache_flush($memcache);
memcache_close($memcache);
}
示例8: afterLictAction
function afterLictAction($queryAssoc, $rowStore)
{
$config = getConfig();
/**
* Count of items page,that need be cached,because
* but last-1/-2/-3/-4 use slow query
*/
$COUNT_BEFORE_END = 5;
$length = $queryAssoc['query']['length'];
$itemsLast = $rowStore['countitems'] % $length;
$lastPage = $rowStore['countitems'] - $itemsLast;
$start = $queryAssoc['query']['start'];
/**
* only for last page
*/
if ($start == $lastPage) {
//last 5 page in cache&
$queryCheckPre = array_merge($queryAssoc, []);
$queryCheckPre['query']['start'] = $start - 1 * $length;
$queryPre = buildListItemQuery($queryCheckPre, $rowStore['countitems']);
$params = $config['memcache'];
$memcache = memcache_connect($params['host'], $params['port']);
$memcacheQueryKey = 'QUERY' . $queryPre['slow'];
$data = memcache_get($memcache, $memcacheQueryKey);
memcache_close($memcache);
//another proc
if (empty($data)) {
$pid = pcntl_fork();
if ($pid == 0) {
$mysqli = db_mysqli_connect($queryAssoc['table']['dbname']);
for ($i = 1; $i < $COUNT_BEFORE_END; $i++) {
$queryAssoc['query']['start'] = $start - $i * $length;
$sqlQueryes = buildListItemQuery($queryAssoc, $rowStore['countitems']);
$rows = db_mysqli_query_fetch_list($mysqli, $sqlQueryes, MYSQLI_ASSOC);
$_SESSION['list'] = ['lastitem' => $rows[count($rows) - 1], 'firstitem' => $rows[0], 'lastpage' => $queryAssoc['query']['start'], 'slowQueryType' => $sqlQueryes['slowQueryType']];
//
usleep(500);
}
db_mysqli_close($mysqli);
exit(0);
//end new proc
}
}
}
}
示例9: test
function test()
{
global $memcache_test_servers;
if (!extension_loaded('memcache') || !class_exists('Memcache')) {
return FALSE;
}
if (empty($memcache_test_servers)) {
return TRUE;
}
// Note: will return true if at least one connection succeeds
foreach ($memcache_test_servers as $memcache_server_info) {
if ($memcache_obj = memcache_connect($memcache_server_info['host'], $memcache_server_info['port'])) {
memcache_close($memcache_obj);
return TRUE;
}
}
return FALSE;
}
示例10: db_mysqli_query_fetch_store
function db_mysqli_query_fetch_store($mysqli, $query, $MYSQLI_TYPE)
{
$config = getConfig();
$params = $config['memcache'];
$memcache = memcache_connect($params['host'], $params['port']);
$memcacheQueryKey = 'QUERY' . md5($query);
$data = memcache_get($memcache, $memcacheQueryKey);
if (!empty($data)) {
} else {
$result = mysqli_query($mysqli, $query);
$data = [];
while ($row = mysqli_fetch_array($result, $MYSQLI_TYPE)) {
$data[] = $row;
}
memcache_set($memcache, $memcacheQueryKey, $data, 0, 60 * 10);
}
memcache_close($memcache);
return $data;
}
示例11: __destruct
function __destruct()
{
memcache_close($this->connection);
}
示例12: push
function push($device_token,$message){
$memcache_obj = memcache_connect('192.168.133.71',21211);
while(list($key,$deviceToken) = each($device_token)){
if($data['payload']=$message){
$data['deviceToken']=$deviceToken;
$output = json_encode($data);
memcache_set($memcache_obj,'pushqueue',$output,0,0);
}
}
memcache_close($memcache_obj);
}
示例13: mkdir
public function mkdir($path, $mode, $options)
{
$path = trim(substr($path, 8));
//echo "回调mkdir\n";
$path = rtrim($path, '/');
$this->stat = $this->get_file_info($path);
$this->stat['ctime'] = $this->stat[10] = time();
$this->stat['mode'] = $this->stat[2] = $this->dir_mode;
//echo "生成新的stat数据" . print_r( $this->stat , 1 );
memcache_set($this->mc(), $path . '.meta', serialize($this->stat));
//echo "写入MC. key= " . $path.'.meta ' . memcache_get( $this->mc , $path.'.meta' );
memcache_close($this->mc);
return true;
}
示例14: disconnect
/**
* Disconnect from remote cache store
*
* @access public
* @return boolean Disconnect successful
*/
public function disconnect()
{
if ($this->link) {
return memcache_close($this->link);
}
return false;
}
示例15: memcache_connect
<?php
$memcache = memcache_connect('10.10.20.93', 11211);
//$memcache = @memcache_connect('localhost', 11211);
try {
if ($memcache) {
echo '{"error_code":"0","error_string":"SUCCESS"}';
memcache_close($memcache);
} else {
echo '{"error_code":"1","error_string":"Connection to memcached failed"}';
}
} catch (Exception $ex) {
echo '{"error_code":"1","error_string":"' . $ex->getMessage() . '"}';
}