本文整理汇总了PHP中phpFastCache类的典型用法代码示例。如果您正苦于以下问题:PHP phpFastCache类的具体用法?PHP phpFastCache怎么用?PHP phpFastCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了phpFastCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCache
protected function setCache(Container $di, $cacheConfig, $basePath)
{
foreach ($cacheConfig as $key => $value) {
\phpFastCache::setup($key, $value);
}
\phpFastCache::setup("path", $basePath . "/var/cache");
$di->set("cache", $di->lazyNew('phpFastCache'));
}
示例2: _initCache
public function _initCache()
{
//$servers = array();
$cacheCfg = $this->_config->memcached->config;
$servers = $cacheCfg->toArray();
if (!empty($servers)) {
phpFastCache::$storage = "auto";
$cache = __c($cacheCfg->type);
$server = array(array($cacheCfg->host, $cacheCfg->port, $cacheCfg->timeout));
$cache->option("server", $server);
Registry::set("cache", $cache);
}
}
示例3: __construct
/**
* Constructor
*/
function __construct($prefix = 'index.php?')
{
global $base_dir, $_SERVER;
phpFastCache::setup('storage', 'files');
phpFastCache::setup('path', $base_dir);
phpFastCache::setup('securityKey', 'cache');
$this->cache = phpFastCache();
$this->id = $_SERVER['QUERY_STRING'];
if ($this->id == '') {
$this->id = 'mod=home';
}
$this->id = $this->prefix . $this->id;
}
示例4: 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;
}
示例5: testAction
public function testAction()
{
phpFastCache::$storage = "auto";
$cache = __c("memcache");
$server = array(array("192.168.10.122", 11211, 100));
$cache->option("server", $server);
$cache->keyword = array("something here++++++++++++++++_________", 600);
// var_dump($cache->get("31lh9kj9cs3627fauu90njuj26"));
var_dump($cache->keyword);
$excel = new CreateExcel();
// $excel->setHeader('高子航' . date('Y年m月d日 H:i:s', time()));
// $excel->setTitle(array( '高子航'));
// $excel->setData(array());
// $excel->echoExcel('show_' . date('Y_m_d_H_i_s', time()));
die;
}
示例6: result
public function result()
{
if ($this->on_cache == true) {
require $this->path . '/phpfastcache/phpfastcache.php';
phpFastCache::setup("storage", "auto");
phpFastCache::setup('path', $this->path . '/phpfastcache/cache/');
$cache = phpFastCache();
$this->data = $cache->get($this->key_cache);
if ($this->data == null) {
$this->data = $this->get_direct();
$cache->set($this->key_cache, $this->data, 86400);
}
} else {
$this->data = $this->get_direct();
}
return $this->data;
}
示例7: phpFastCache
function phpFastCache($storage = "auto", $config = array())
{
$storage = strtolower($storage);
if (empty($config)) {
$config = phpFastCache::$config;
}
if ($storage == "" || $storage == "auto") {
$storage = phpFastCache::getAutoClass($config);
}
$instance = md5(json_encode($config) . $storage);
if (!isset(phpFastCache_instances::$instances[$instance])) {
$class = "phpfastcache_" . $storage;
phpFastCache::required($storage);
phpFastCache_instances::$instances[$instance] = new $class($config);
}
return phpFastCache_instances::$instances[$instance];
}
示例8: 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;
}
示例9: __construct
public function __construct()
{
$system = CoreLoader::$system;
date_default_timezone_set($system['default_timezone']);
$this->registerErrorHandle();
$this->router = CoreInput::$router;
$this->input = new CoreInput();
$this->model = new CoreModelLoader();
$this->lib = new CoreLibLoader();
$this->rule = new CoreRule();
$this->cache = phpFastCache::getInstance($system['cache_config']['storage'], $system['cache_config']);
if ($system['autoload_db']) {
$this->database();
}
if (!empty($system['language'])) {
self::$locale = new CoreLocale($system['language']);
}
Fn::stripslashes_all();
}
示例10: 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;
}
示例11: dirname
<?php
include 'config.php';
require "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
phpFastCache::setup("path", dirname(__FILE__) . '/cache');
// Path For Files
//User Whitelist Check
if (!in_array($username, $user_whitelist)) {
echo "Clever girl... But you're not on the list. <a href='http://goo.gl/forms/0wgJeVpIaI'>Request Access</a>";
exit;
}
// Set Caching
$cache = phpFastCache();
// Try to get $content from Caching First
// product_page is "identity keyword";
$link = $cache->get($username);
if ($link == null) {
$connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
$content = $connection->get(API_KIND, array("screen_name" => $username, "count" => intval(POSTS_COUNT)));
if (empty($content->errors)) {
//All is dandy
foreach ($content as $tweet_object) {
$urls = $tweet_object->entities->urls;
//Get URLS
foreach ($urls as $url) {
//$debug = $url->expanded_url;
if (strpos($url->display_url, 'periscope.tv') !== false) {
//Find periscope link
$link = $url->expanded_url;
}
示例12: 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}");
}
示例13: cometchatMemcacheConnect
function cometchatMemcacheConnect()
{
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
global $memcache;
if (MEMCACHE != 0 && MC_NAME == 'memcachier') {
$memcache = new MemcacheSASL();
$memcache->addServer(MC_SERVER, MC_PORT);
$memcache->setSaslAuthData(MC_USERNAME, MC_PASSWORD);
} elseif (MEMCACHE != 0) {
phpFastCache::setup("path", dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache');
phpFastCache::setup("storage", MC_NAME);
$memcache = phpFastCache();
}
}
示例14: dirname
<?php
// phpFastCache Library
require_once dirname(__FILE__) . "/phpfastcache/2.4.2/base.php";
// OK, setup your cache
phpFastCache::$storage = "files";
//memcache
phpFastCache::$config = array("storage" => phpFastCache::$storage, "fallback" => "files", "securityKey" => "auto", "htaccess" => true, "path" => "", "memcached" => array(array("127.0.0.1", 11211, 1)), "memcache" => array(array("127.0.0.1", 11211, 1)), "server" => array(array("127.0.0.1", 11211, 1)), "redis" => array("host" => "127.0.0.1", "port" => "", "password" => "", "database" => "", "timeout" => ""), "extensions" => array());
phpFastCache::setup(phpFastCache::$config);
// temporary disabled phpFastCache
phpFastCache::$disabled = false;
// default chmod | only change if you know what you are doing
phpFastCache::$default_chmod = "";
// keep it blank, it will use 666 for module and 644 for cgi
示例15: mysql_select_db
$NameBD = $cmd->parametro->get("NameBD");
}
$bool = mysql_select_db($NameBD, $connect);
$q = mysql_query('select * from bsw_bi.bi_server where dbName="' . $NameBD . '"');
if (mysql_num_rows($q) == 1) {
$_SESSION['id_server'] = mysql_result($q, 0);
} else {
die($LANG_ERROR_BI);
}
} catch (Exception $e) {
print $LANG_ERROR_CONNECT . " {$database}";
}
include_once "fast/phpfastcache/phpfastcache.php";
phpFastCache::setup("storage", "auto");
if (php_uname("s") == "Darwin") {
phpFastCache::setup("path", '/private/var/tmp');
}
// Path For Files includes/work must be in 777
function readDashboardSections()
{
$q = 'select distinct dashboard
from bi_dashboard,bm_items_groups
where bi_dashboard.id_item=bm_items_groups.id_item and
bm_items_groups.groupid=' . $_SESSION['groupid'] . '
order by displayorder';
$q1 = mysql_query($q);
while ($r = mysql_fetch_array($q1, MYSQL_ASSOC)) {
$data[] = array('dashboard' => $r['dashboard']);
}
return $data;
}