本文整理汇总了PHP中phpFastCache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFastCache::get方法的具体用法?PHP phpFastCache::get怎么用?PHP phpFastCache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpFastCache
的用法示例。
在下文中一共展示了phpFastCache::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Set Cache
*/
public static function get($keyword, $nousercache = 0)
{
if ($nousercache == 0) {
$key = $keyword . SessionAccountHandler::getId();
$cachedobj = self::$cache->getinfo($key);
$lastcacheclean = self::$LASTCLEAN;
if ($lastcacheclean === null) {
$lastcacheclean = self::$cache->get('LASTCLEAN' . SessionAccountHandler::getId());
$lastcacheclean = $lastcacheclean ?: 0;
self::$LASTCLEAN = $lastcacheclean;
}
if (isset($cachedobj['write_time']) && $cachedobj['write_time'] > $lastcacheclean) {
return $cachedobj['value'];
} else {
return null;
}
} else {
return self::$cache->get($keyword);
}
}
示例2: SSLForwardJS
public function SSLForwardJS()
{
$ip = $this->getRealIP();
if (!class_exists("phpFastCache")) {
die("Please required phpFastCache Class");
}
// you should change this to cURL()
$data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
// caching 1 week
if ($data == null) {
$url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
$data = file_get_contents($url);
phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
}
return $data;
}
示例3: SSLForwardJS
public function SSLForwardJS()
{
$ip = $this->getRealIP();
if (!class_exists("phpFastCache")) {
die("<div style='border: 2px solid #09f; font-size: .8em; font-family: Arial;background: #FCF0F0;border: 2px solid #F07272;padding: 10px;'>Please enable plugin <b>Cache</b> to run plugin <b>Statistic</b>!</div>");
}
// you should change this to cURL()
$data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
// caching 1 week
if ($data == null) {
$ctx = stream_context_create(array('http' => array('timeout' => 0.5)));
$url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
$json = file_get_html($url);
phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
}
return $data;
}
示例4: getLocation
public function getLocation($ip = "")
{
if ($ip == "") {
$ip = $this->getRealIP();
}
if (!class_exists("phpFastCache")) {
die("Please required phpFastCache Class");
}
// you should change this to cURL()
$data = phpFastCache::get("codehelper_ip_" . md5($ip));
// caching 1 week
if ($data == null) {
$url = "http://api.codehelper.io/ips/?php&ip=" . $ip;
$json = file_get_contents($url);
$data = json_decode($json, true);
phpFastCache::set("codehelper_ip_" . md5($ip), $data, 3600 * 24 * 7);
}
return $data;
}
示例5: 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}");
}
示例6:
<?php
include "php_fast_cache.php";
phpFastCache::$storage = "auto";
// ready ?
// check in case first
$content = phpFastCache::get("keyword1");
if ($content == null) {
// for testing
echo "This is not caching, page is render with lot queires and slow speed <br>";
// do what you want, like get content from cURL | API | mySQL Query and return result to $content
$content = file_get_contents("http://www.phpfastcache.com/testing.php");
// rewrite cache for other request in 5 seconds
phpFastCache::set("keyword1", $content, 5);
} else {
// use cache
// node
echo "THIS TIME USE CACHE, FAST! <br>";
}
echo "TRY F5 to refesh the page to see new SPEED with Cache!<br>";
echo $content;
示例7: print_r
phpFastCache::set("A" . $dem, $string);
echo "GET {$dem} = ";
$x = phpFastCache::get("A" . $dem);
if (is_array($x)) {
print_r($x);
} else {
echo $x;
if (is_numeric($x)) {
phpFastCache::increment("A" . $dem);
phpFastCache::increment("A" . $dem);
phpFastCache::increment("A" . $dem);
$x = phpFastCache::get("A" . $dem);
echo " Increase to " . $x;
phpFastCache::decrement("A" . $dem);
phpFastCache::decrement("A" . $dem);
phpFastCache::decrement("A" . $dem);
$x = phpFastCache::get("A" . $dem);
echo " Decrease to " . $x;
}
}
phpFastCache::delete("A" . $dem);
echo " || Finished Testing || Deleted ";
echo "<br>";
}
} else {
echo " <-- NOT SUPPORTED ON THIS SERVER WITH DEFAULT CONFIG 127.0.0.1 <br>";
}
echo "</font>";
}
echo "<hr>";
phpinfo();
示例8: 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}");
}
示例9: array
}
$cacheReset = FALSE;
if (isset($_GET["cache"]) && $_GET["cache"] == "reset") {
$cacheReset = TRUE;
}
$limit = 107;
#if($testing) $limit=3;
$outputFile = '/tmp/results.csv';
$outputContent = '';
$ridingsNames = array();
$resultsByRidingByParty = array();
$resultsByPartyByRiding = array();
$resultsByRidingSummary = array();
$wastedVotesByParty = array();
### Check first caching
$content = phpFastCache::get("main");
if ($content !== null && strlen($content) > 500 && $cacheReset !== TRUE) {
$content .= '<p><font size="-1">Cached results printed on ' . date($dateFormat) . '</font></p>';
printf("%s", $content);
} else {
### Get the riding list first and objects
#$url = 'http://www.gnb.ca/elections/results-resultats/2014-09-22/2014-09-22-resultshtml-e.asp';
$url = 'http://www.gnb.ca/elections/results-resultats/2014-09-22/2014-09-22-results-e.asp';
webCommentPrint('Getting page....');
$html = file_get_contents($url);
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($html);
libxml_use_internal_errors(false);
$xpath = new DOMXPath($doc);
### Lets get the riding names