本文整理匯總了PHP中phpFastCache::option方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpFastCache::option方法的具體用法?PHP phpFastCache::option怎麽用?PHP phpFastCache::option使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpFastCache
的用法示例。
在下文中一共展示了phpFastCache::option方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updatecaching
function updatecaching()
{
global $ts;
$conn = 1;
$errorCode = 0;
$memcacheAuth = 0;
include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
if ($_POST['MC_NAME'] == 'memcachier') {
$memcacheAuth = 1;
$conn = 0;
$memcache = new MemcacheSASL();
$memcache->addServer($_POST['MC_SERVER'], $_POST['MC_PORT']);
if ($memcachierAuth = $memcache->setSaslAuthData($_POST['MC_USERNAME'], $_POST['MC_PASSWORD'])) {
$memcache->set('auth', 'ok');
if (!($conn = $memcache->get('auth'))) {
$errorCode = 3;
}
$memcache->delete('auth');
} else {
$errorCode = 3;
}
} elseif ($_POST['MC_NAME'] != '') {
$conn = 0;
$memcacheAuth = 1;
phpFastCache::setup("storage", $_POST['MC_NAME']);
$memcache = new phpFastCache();
$driverPresent = isset($memcache->driver->option['availability']) ? 0 : 1;
if ($driverPresent) {
if ($_POST['MC_NAME'] == 'memcache') {
$server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
$memcache->option('server', $server);
}
$memcache->set('auth', 'ok', 30);
if (!($conn = $memcache->get('auth'))) {
$errorCode = 1;
}
$memcache->delete('auth');
}
}
if ($conn && !$errorCode) {
$data = 'define(\'MEMCACHE\',\'' . $memcacheAuth . '\');' . "\r\n";
$data .= 'define(\'MC_SERVER\',\'' . $_POST['MC_SERVER'] . '\');' . "\t// Set name of your memcache server\r\n";
$data .= 'define(\'MC_PORT\',\'' . $_POST['MC_PORT'] . '\');' . "\t\t\t// Set port of your memcache server\r\n";
$data .= 'define(\'MC_USERNAME\',\'' . $_POST['MC_USERNAME'] . '\');' . "\t\t\t\t\t\t\t// Set username of memcachier server\r\n";
$data .= 'define(\'MC_PASSWORD\',\'' . $_POST['MC_PASSWORD'] . '\');' . "\t\t\t// Set password your memcachier server\r\n";
$data .= 'define(\'MC_NAME\',\'' . $_POST['MC_NAME'] . '\');' . "\t\t\t// Set name of caching method if 0 : '', 1 : memcache, 2 : files, 3 : memcachier, 4 : apc, 5 : wincache, 6 : sqlite & 7 : memcached";
configeditor('MEMCACHE', $data, 0);
$_SESSION['cometchat']['error'] = 'Caching details updated successfully.';
} else {
if ($_POST['MC_NAME'] == 'memcachier') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memchachier server details';
} elseif ($_POST['MC_NAME'] == 'files') {
$_SESSION['cometchat']['error'] = 'Please check file permission of your cache directory. Please try 755/777/644';
} elseif ($_POST['MC_NAME'] == 'apc') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your APC configuration.';
} elseif ($_POST['MC_NAME'] == 'wincache') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Wincache configuration.';
} elseif ($_POST['MC_NAME'] == 'sqlite') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your SQLite configuration.';
} elseif ($_POST['MC_NAME'] == 'memcached') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcached configuration.';
} else {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcache server configuration.';
}
}
header("Location:?module=settings&action=caching&ts={$ts}");
}
示例2: updatecaching
function updatecaching()
{
global $ts;
$conn = 1;
$errorCode = 0;
$memcacheAuth = 0;
include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
if ($_POST['MC_NAME'] == 'memcachier') {
$memcacheAuth = 1;
$conn = 0;
$memcache = new MemcacheSASL();
$memcache->addServer($_POST['MC_SERVER'], $_POST['MC_PORT']);
if ($memcachierAuth = $memcache->setSaslAuthData($_POST['MC_USERNAME'], $_POST['MC_PASSWORD'])) {
$memcache->set('auth', 'ok');
if (!($conn = $memcache->get('auth'))) {
$errorCode = 3;
}
$memcache->delete('auth');
} else {
$errorCode = 3;
}
} elseif ($_POST['MC_NAME'] != '') {
$conn = 0;
$memcacheAuth = 1;
phpFastCache::setup("storage", $_POST['MC_NAME']);
$memcache = new phpFastCache();
$driverPresent = isset($memcache->driver->option['availability']) ? 0 : 1;
if ($driverPresent) {
if ($_POST['MC_NAME'] == 'memcache' && class_exists("Memcache") || $_POST['MC_NAME'] == 'memcached' && class_exists("Memcached")) {
if ($_POST['MC_NAME'] == 'memcache') {
$server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
$memcache->option('server', $server);
}
if ($_POST['MC_NAME'] == 'memcached') {
$server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
$memcache->option('server', $server);
}
$memcache->set('auth', 'ok', 30);
if (!($conn = $memcache->get('auth'))) {
$errorCode = 1;
}
$memcache->delete('auth');
}
}
}
if (!$errorCode) {
configeditor($_POST);
$_SESSION['cometchat']['error'] = 'Caching details updated successfully.';
} else {
if ($_POST['MC_NAME'] == 'memcachier') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memchachier server details';
} elseif ($_POST['MC_NAME'] == 'files') {
$_SESSION['cometchat']['error'] = 'Please check file permission of your cache directory. Please try 755/777/644';
} elseif ($_POST['MC_NAME'] == 'apc') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your APC configuration.';
} elseif ($_POST['MC_NAME'] == 'wincache') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Wincache configuration.';
} elseif ($_POST['MC_NAME'] == 'sqlite') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your SQLite configuration.';
} elseif ($_POST['MC_NAME'] == 'memcached') {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcached configuration.';
} else {
$_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcache server configuration.';
}
}
header("Location:?module=settings&action=caching&ts={$ts}");
}