本文整理汇总了PHP中phpFastCache函数的典型用法代码示例。如果您正苦于以下问题:PHP phpFastCache函数的具体用法?PHP phpFastCache怎么用?PHP phpFastCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phpFastCache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFeed
/**
* @return array
*/
public function getFeed($params = [])
{
/** @var Page $page */
$page = $this->grav['page'];
/** @var Twig $twig */
$twig = $this->grav['twig'];
/** @var Data $config */
$config = $this->mergeConfig($page, TRUE);
// Autoload composer components
require __DIR__ . '/vendor/autoload.php';
// Set up cache settings
$cache_config = array("storage" => "files", "default_chmod" => 0777, "fallback" => "files", "securityKey" => "auto", "htaccess" => true, "path" => __DIR__ . "/cache");
// Init the cache engine
$this->cache = phpFastCache("files", $cache_config);
// Generate API url
$url = 'https://api.instagram.com/v1/users/' . $config->get('feed_parameters.user_id') . '/media/recent/?access_token=' . $config->get('feed_parameters.access_token');
// Get the cached results if available
$results = $this->cache->get($url);
// Get the results from the live API, cached version not found
if ($results === null) {
$results = Response::get($url);
// Cache the results
$this->cache->set($url, $results, InstagramPlugin::HOUR_IN_SECONDS * $config->get('feed_parameters.cache_time'));
// Convert hours to seconds
}
$this->parseResponse($results);
$this->template_vars = ['user_id' => $config->get('feed_parameters.user_id'), 'client_id' => $config->get('feed_parameters.client_id'), 'feed' => $this->feeds, 'count' => $config->get('feed_parameters.count')];
$output = $this->grav['twig']->twig()->render($this->template_html, $this->template_vars);
return $output;
}
示例2: __construct
function __construct($storage = "", $config = array())
{
$config = array_merge(phpFastCache::$config, $config);
$config['storage'] = $storage;
$storage = strtolower($storage);
if ($storage == "" || $storage == "auto") {
$storage = self::getAutoClass($config);
}
$this->instance = phpFastCache($storage, $config);
}
示例3: onPluginsLoaded
/**
* onPluginsLoaded method
*/
public function onPluginsLoaded()
{
// phpFastCache not working in CLI mode...
if (PHILE_CLI_MODE) {
return;
}
unset($this->settings['active']);
$config = $this->settings + \phpFastCache::$config;
$storage = $this->settings['storage'];
$cache = phpFastCache($storage, $config);
ServiceLocator::registerService('Phile_Cache', new PhpFastCache($cache));
}
示例4: __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;
}
示例5: __construct
/**
* Constructor
*
* @param array
*/
public function __construct()
{
$CI =& get_instance();
$CI->config->load('fastcache');
//unique failsafe token for each project
if (!file_exists(APPPATH . 'cache/fastcache_token.php')) {
$token = md5(uniqid(mt_rand(), true));
file_put_contents(APPPATH . 'cache/fastcache_token.php', '<?php ' . "ªn" . '$token=\'' . $token . '\';');
} else {
include APPPATH . 'cache/fastcache_token.php';
}
$this->token = $token;
$c = $CI->config->item('fastcache');
$this->cache = phpFastCache($c['storage'], $CI->config->item('fastcache'));
}
示例6: getPhotosByHighglithFirst
function getPhotosByHighglithFirst($category)
{
global $detect;
$cache = phpFastCache();
if (isset($_GET['clear_cache'])) {
$cache->delete('posts');
}
$posts = $cache->get("posts");
if (!$posts || $posts == null) {
$posts = getPhotos($category, false);
$posts = getPhotos($category, $posts);
// cache for an hour
$cache->set("posts", $posts, 3000);
}
return $posts;
}
示例7: 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;
}
示例8: get_shahinfo
/**
* 获得详情页数据
*/
function get_shahinfo($hash)
{
if (preg_match('/^[0-9A-Z]+$/u', $hash)) {
$cache = phpFastCache("files", array("path" => "cache"));
$conter = $cache->get($hash);
if (is_null($conter)) {
$url = 'http://www.torrentkitty.org/information/';
$content = get_data($url . $hash);
$html = new simple_html_dom();
$html->load($content);
@($ret = $html->find('h3'));
if (isset($ret['0']->nodes['0']->_['4']) && $ret['0']->nodes['0']->_['4'] == 'Magnet Link does not eixst. You may try to upload it again.') {
$info['error'] = TRUE;
} else {
foreach ($html->find('.magnet-link') as $article) {
$item['magnet'] = $article->plaintext;
$articles[] = $item;
}
foreach ($html->find('.detailSummary') as $article) {
foreach ($article->find('tr') as $tr) {
foreach ($article->find('td') as $td) {
$item[] = $td->plaintext;
}
}
}
preg_match('%<table[^>]*id="torrentDetail"[^>]*>(.*?) </table>%si', $content, $match);
preg_match('%<h2>(.*?)</h2>%si', $content, $ret);
$title = mb_substr($ret['0'], 25);
$info['title'] = strip_tags($title);
$info['list'] = $match;
$info['size'] = $item['3'];
$info['quantity'] = $item['2'];
$info['cdate'] = $item['4'];
$info['magnetic'] = $articles['0']['magnet'];
$cache->set($hash, $info, 864000);
}
} else {
$info = $conter;
}
} else {
$info['error'] = TRUE;
}
return $info;
}
示例9: 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();
}
}
示例10: loadRAWData
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null)
{
$cacheAge = 60 * 60;
$offset = getOffset();
setTimezone();
$cache = phpFastCache();
//$cache->clean();
$dt = getDates($from);
$from = $dt[0];
if ($to == null) {
$to = $dt[1];
}
$from = str_replace("-", "/", $from);
$to = str_replace("-", "/", $to);
$phour = getPeakHours();
$unit = getUnit($id_item);
$plan = getPlan($id_plan);
$item = getItem($id_item);
$div = 1;
if (strtolower($unit) == 'bps') {
$div = 1024 * 1024;
$unit = 'Mbps';
}
$rtag = "";
foreach ($_SESSION['tag'] as $key => $value) {
if ($key != "" && $key != "None") {
$rtag = $rtag . ',"' . $key . '"';
}
}
if ($rtag == '') {
$rtag = 'bm_tags.tag like "%"';
} else {
$rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')';
}
if ($id_plan == 0) {
$id_plan = '> 0';
} else {
$id_plan = '=' . $id_plan;
}
if ($id_host == null) {
$id_host = "";
} else {
$id_host = " and bm_host.id_host=" . $id_host;
}
$hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host
from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard
where bm_host.id_plan=bm_plan.id_plan
and bm_host.groupid = ' . $_SESSION['groupid'] . '
and bm_plan.id_plan ' . $id_plan . '
and bm_plan_groups.id_plan = bm_plan.id_plan
and bm_host.borrado=0
and bm_host.id_plan=bm_plan.id_plan
and bm_plan_groups.groupid=bm_host.groupid
and bm_threshold.id_item=bi_dashboard.id_item
and bm_host.id_host in (select id from bm_tags where ' . $rtag . ')
and bi_dashboard.id_item=' . $id_item . $id_host . '
order by bm_host.id_plan';
//var_dump($hosts);
// Find Percentile 5 and 95
if (true) {
$hostsr = mysql_query($hosts);
while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) {
$id_host = $host['id_host'];
$hostName = $host['host'];
$nominal = $host['nominal'];
$critical = $host['critical'];
$warning = $host['warning'];
$nacD = $host['nacD'] * 1024;
$nacU = $host['nacU'] * 1024;
if ($nominal == -1) {
$nominal = $nacD;
}
if ($nominal == -2) {
$nominal = $nacU;
}
$hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU);
$incache = true;
unset($cachedData);
$dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days'));
while ($dfrom != $to) {
$dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days'));
$key = $dfrom . '-' . $id_host . '-' . $id_item;
//if (isset($_SESSION['cache'][$key]))
// $obj = $_SESSION['cache'][$key];
//else
//echo $key . "<br>";
$obj = $cache->get($key);
if ($obj == null) {
$incache = false;
$_SESSION['cacheFull'] = false;
} else {
$_SESSION['cachePartial'] = true;
foreach ($obj as $key => $value) {
if (isset($value['clock'])) {
$cachedData[] = $value;
}
}
}
}
if (!isset($cachedData)) {
//.........这里部分代码省略.........
示例11: array
/* edition, for createing a weighted average. */
$gStatsWPEditions = array('zh' => 935, 'en' => 387, 'es' => 365, 'hi' => 295, 'ar' => 295);
/* Gallery images are picked from pictures */
/* in Wikipedia articles. What WP editions should */
/* we scan for images? */
$gImageSourceWPEditions = array('en', 'es', 'de', 'nl');
// ruwp contains a lot pf portraits as genre pictures,
// hence commenting out
/* When retriving images from Wikipedia pages, we */
/* want to exclude some pics that are often used */
/* to illustrate navigation boxes and similar. */
/* NB: Space, not underscore in filenames! */
$gImageBlacklist = array('Tom Sawyer 1876 frontispiece.jpg', 'Nobel Prize.png', 'Дмитрий Иванович Менделеев 8.jpg', 'Charles_Darwin_1880.jpg', 'Agnes von Kurowsky in Milan.jpg', 'Merton College front quad.jpg', 'St John\'s Church, Little Gidding.jpg', 'Vivienne Haigh-Wood Eliot 1920.jpg', 'Harper Midway Chicago.jpg', 'University of Minnesota-20031209.jpg', 'Bronze Star medal.jpg', 'Air Medal front.jpg', 'Meritorious Service Medal (United_States).png', 'Purpleheart.jpg', 'Dfc-usa.jpg', 'Us legion of merit legionnaire.png', 'Silver Star medal.png', 'Conservative Elephant.png', '2006 AEGold Proof Obv.png');
/* Cache type. Can be auto, memcache, files, etc. */
/* see http://www.phpfastcache.com/ for full list */
$gCache = phpFastCache("auto");
# Example, using a local Redis server:
#$gCache = phpFastCache("redis");
#$gCache->config['redis']['server'] = '127.0.0.1';
#$gCache->config['redis']['port'] = '6379';
/* The number of hours to cache external data on */
/* individual laureates, e.g. Wikipedia images */
$gExternalLaureateDataCacheTime = 720;
/* The number of hours to store external stats, */
/* e.g. Wikipedia pageviews */
$gExternalStatsCacheTime = 36;
/* Should we cache responses from local API's? If */
/* our caching is not superfast, and API's are on */
/* on the same server, it might be faster not to. */
$gCacheLocal = true;
/* Time zone to use when fetching statistics */
示例12: mysqli_select_db
if (!$dbh) {
echo "<h3>Unable to connect to database. Please check details in configuration file.</h3>";
exit;
}
mysqli_select_db($dbh, DB_NAME);
mysqli_query($GLOBALS['dbh'], "SET NAMES utf8");
mysqli_query($GLOBALS['dbh'], "SET CHARACTER SET utf8");
mysqli_query($GLOBALS['dbh'], "SET COLLATION_CONNECTION = 'utf8_general_ci'");
if (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(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'cache');
phpFastCache::setup("storage", MC_NAME);
$memcache = phpFastCache();
$memcache->set('auth', 'o1k', 30);
}
$usertable = TABLE_PREFIX . DB_USERTABLE;
$usertable_username = DB_USERTABLE_NAME;
$usertable_userid = DB_USERTABLE_USERID;
$body = '';
if (!empty($_POST['username'])) {
$_SESSION['cometchat']['cometchat_admin_user'] = $_POST['username'];
}
if (!empty($_POST['password'])) {
$_SESSION['cometchat']['cometchat_admin_pass'] = $_POST['password'];
}
authenticate();
$module = "dashboard";
$action = "index";
示例13: __construct
/**
* Constructor.
* @access public
*
*/
public function __construct()
{
// Auto-load classes on demand
if (function_exists("__autoload")) {
spl_autoload_register("__autoload");
}
spl_autoload_register(array($this, 'autoload'));
// Define constants
$this->define_constants();
// Include required files
$this->includes();
$this->API_key = "b01d4d3fea131c822c72eb8c3e9d85b83c2beac92ac9fab197e932c4b20a71c0";
//"a871cfc48ef1ee01f27d7c773aacd6a7c5b2ae80203d0401c3f0c1fc8354f0a2";
$this->API_account = "83442";
// Init API
$this->api = new LI_API($this->API_key, $this->API_account);
// simple Caching with:
$this->LI_cache = phpFastCache();
// set xml directory
$this->XML_dir_matrices = $this->plugin_path() . '/xml/matrices/';
// set xml directory
$this->XML_dir_items = $this->plugin_path() . '/xml/items/';
// set xml directory
$this->XML_dir_vendors = $this->plugin_path() . '/xml/vendors/';
$this->XML_dir_manufacturers = $this->plugin_path() . '/xml/manufacturers/';
//$this->options = get_option('lightspeed_inteleck_options');
/*if(is_admin()) {
require_once(LSI_DIR_PATH.'views/lsi-options.php'); // include options file
$options_page = new lightspeedImportOptions();
add_action('admin_menu', array($options_page, 'add_pages')); // adds page to menu
add_action('admin_init', array($options_page, 'register_settings'));
}*/
register_activation_hook(__FILE__, array($this, 'lightspeed_import_activation'));
register_deactivation_hook(__FILE__, array($this, 'lightspeed_import_deactivation'));
add_action('lightspeed_hourly_product_import', array($this, 'lightspeed_import_items'));
add_action('lightspeed_hourly_matrices_import', array($this, 'lightspeed_import_matrices'));
add_action('lightspeed_hourly_vendors_import', array($this, 'lightspeed_import_vendors'));
add_action('lightspeed_hourly_manufacturers_import', array($this, 'lightspeed_import_manufacturers'));
}
示例14: Cache
public function Cache()
{
$this->control = Control::getControl();
$this->phpFastCache = phpFastCache();
}
示例15: loadApontamentosDiasDistintos
public function loadApontamentosDiasDistintos($connection, $tipoApontamento)
{
$cache = phpFastCache();
$apontamentosCache = $cache->get("ApontamentosDiasDistintos" . $tipoApontamento);
if ($apontamentosCache != null) {
return $apontamentosCache;
} else {
$registros = array();
$query = " SELECT *\n FROM apontamentos\n WHERE apo_dtdinicio NOT LIKE '%0000%'\n AND apo_dtdfim NOT LIKE '%0000%'\n AND DAY(apo_dtdinicio) <> DAY(apo_dtdfim) ";
if (!Functions::isEmpty($tipoApontamento) && $tipoApontamento == "A") {
$query .= " AND apo_cdiatividade IS NOT NULL ";
}
if (!Functions::isEmpty($tipoApontamento) && $tipoApontamento == "C") {
$query .= " AND apo_cdichamado IS NOT NULL ";
}
$query .= " ORDER BY apo_cdiapontamento ";
$stmt = $connection->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
$vo = $this->populateVo($connection, $row);
array_push($registros, $vo);
}
$cache->set("ApontamentosDiasDistintos" . $tipoApontamento, $registros, 60 * Functions::getParametro('cache'));
return $registros;
}
}