本文整理汇总了PHP中Cache::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::init方法的具体用法?PHP Cache::init怎么用?PHP Cache::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
if (!func::extensionLoaded('apc')) {
throw new Exception('CApcCache requires PHP apc extension to be loaded.');
}
}
示例2: init
public function init()
{
parent::init();
if (!function_exists('eaccelerator_get')) {
throw new Exception('CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.');
}
}
示例3: __construct
/**
* Constructor.
*
* @access protected
*/
protected function __construct()
{
// Init Config
Config::init();
// Turn on output buffering
ob_start();
// Display Errors
Config::get('system.errors.display') and error_reporting(-1);
// Set internal encoding
function_exists('mb_language') and mb_language('uni');
function_exists('mb_regex_encoding') and mb_regex_encoding(Config::get('system.charset'));
function_exists('mb_internal_encoding') and mb_internal_encoding(Config::get('system.charset'));
// Set default timezone
date_default_timezone_set(Config::get('system.timezone'));
// Start the session
Session::start();
// Init Cache
Cache::init();
// Init Plugins
Plugins::init();
// Init Blocks
Blocks::init();
// Init Pages
Pages::init();
// Flush (send) the output buffer and turn off output buffering
ob_end_flush();
}
示例4: delete
public static function delete($key)
{
if (Cache::$_selfInstance == null) {
Cache::init();
}
Cache::$_selfInstance->_mc->delete($key);
}
示例5: getLovedSongs
/**
* getLovedSongs()
* Gets user's loved songs. From cache file or from the feed.
*
* @return array $songs Returns formatted songs
*/
public static function getLovedSongs($username = '', $num_songs = 30)
{
if (!self::isValidUsername($username)) {
return array(self::$error);
}
// Check Feeder and Cache classes are accessible
if (!class_exists('Feeder')) {
return array('Could not find Feeder.class.php.');
}
if (!class_exists('Cache')) {
return array('Could not find Cache.class.php.');
}
self::$username = $username;
self::$num_songs = $num_songs;
$cache_filename = self::$username . '-loved-tracks.cache';
$cache_life = 86400;
// 1 day
Cache::init($cache_filename, $cache_life);
if (Cache::cacheFileExists()) {
return Cache::getCache();
}
$song_data = Feeder::getItems(self::getLovedSongsFeed(), self::$num_songs, array('title', 'link'));
if (!is_array($song_data)) {
self::$error = "Last.fm loved tracks feed not found";
return array(self::$error);
}
$songs = self::formatSongData($song_data);
Cache::setCache($songs);
return $songs;
}
示例6: setUp
protected function setUp()
{
parent::setUp();
error_reporting(E_ALL ^ E_NOTICE);
Cache::init('volatile');
$_SESSION["user_id"] = "1";
Application::$config['log_level'] = 550;
}
示例7: getInstance
/**
* 取得缓存类实例
* @static
* @access public
* @return mixed
*/
static function getInstance($type = '', $options = array())
{
static $_instance = array();
$guid = $type . to_guid_string($options);
if (!isset($_instance[$guid])) {
$obj = new Cache();
$_instance[$guid] = $obj->init($type, $options);
}
return $_instance[$guid];
}
示例8: getCode
public function getCode()
{
$cache = Cache::init('memcache')->get('code');
if ($cache) {
return $cache;
}
$res = $this->getColumn(array('id' => 4), 'code');
Cache::init('memcache')->set('code', $res);
return $res;
}
示例9: getCache
static final function getCache()
{
if (isset(self::$cache)) {
return self::$cache;
} else {
$cache = new Cache();
$cache->init(C('cache'));
self::$cache = $cache;
return $cache;
}
}
示例10: bootstrap
public static function bootstrap(array $config)
{
if (!isset($config['mode'])) {
$config['mode'] = Config::get('deploy')->mode;
}
Debug::init($config['debug']);
self::$_MODE = $config['mode'];
self::setErrorReporting($config['mode'] !== self::MODE_PRODUCTION);
Cache::init();
Debug::getInstance()->addCheckpoint('bootstrapped');
}
示例11: del_memcache
/**
* 清除Memcache缓存
*/
public function del_memcache()
{
if (!IS_POST) {
$this->error("页面不存在!");
}
$host = Q("post.host");
$port = Q("post.port", null, "intval");
$time = Q("post.time", null, "intval");
$cache = Cache::init(array("driver" => "memcache", "host" => array("host" => $host, "port" => $port)));
$time ? $cache->delAll($time) : $cache->delAll();
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$this->success('缓存已经全部删除成功', $url);
}
示例12: init
public function init($cachePath = null)
{
parent::init();
if ($cachePath) {
$this->cachePath = $cachePath;
}
if ($this->cachePath === null) {
$this->cachePath = CShop::$corepath . DIRECTORY_SEPARATOR . 'cache';
}
if (!is_dir($this->cachePath)) {
mkdir($this->cachePath, 0777, true);
}
}
示例13: getBooksFromShelf
/**
* getBooksFromShelf()
* Gets the array of books from a cache_file if found (and less than a week old).
* If no cache_file is found it creates this array of books and adds them to the cache_file - for fast loading next time
*
* @return array Returns a nicely formatted array of books
*/
private static function getBooksFromShelf()
{
$cache_filename = self::$goodreads_id . '-' . self::$shelf . '.cache';
$cache_life = 604800;
// 1 week
Cache::init($cache_filename, $cache_life);
if (Cache::cacheFileExists()) {
return Cache::getCache();
}
$book_data = Feeder::getItems(self::getGoodreadsFeed(), self::$num_books, array('title', 'author_name'));
if (!is_array($book_data)) {
self::$error = "Goodreads feed does not exist. Check user: " . self::$goodreads_id . " and shelf: '" . self::$shelf . "' exist";
return array(self::$error);
}
$books = self::formatBookData($book_data);
Cache::setCache($books);
return $books;
}
示例14: cache_collect
/**
* 缓存选择
* @param string $key 缓存键名
* @param number $set 是否写入缓存,0为读取,1为写入
* @param string $value 缓存内容
* @param string $prefix 缓存的前缀
* @param string $mod 缓存模式
* @param number $expire 缓存时间
* @param string $dir 缓存目录
* @return boolean string $result 读取模式时为读取的内容,写入模式时为0或1
*/
public function cache_collect($key, $set = 0, $value = "", $prefix = "", $mod = "file", $expire = 36000, $dir = "")
{
if ($mod == "file") {
if ($dir) {
$driver = array("driver" => $mod, "dir" => $dir);
} else {
$driver = array("driver" => $mod, "dir" => ROOT_PATH . "Cache/Data");
}
} elseif ($mod == "memcache") {
$driver = array("driver" => $mod, "host" => array("host" => "127.0.0.1", "port" => 11211), "timeout" => 1, "weight" => 1);
}
$driver["zip"] = true;
$driver["prefix"] = $prefix;
$driver["expire"] = $expire;
$cache = Cache::init($driver);
if ($set) {
$result = $cache->{$key} = $value;
} else {
$result = $cache->{$key};
}
return $result;
}
示例15: XTemplate
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('admin', 'a');
cot_block($usr['isadmin']);
$t = new XTemplate(cot_tplfile('admin.cache', 'core'));
$adminpath[] = array(cot_url('admin', 'm=other'), $L['Other']);
$adminpath[] = array(cot_url('admin', 'm=cache'), $L['adm_internalcache']);
$adminsubtitle = $L['adm_internalcache'];
/* === Hook === */
foreach (cot_getextplugins('admin.cache.first') as $pl) {
include $pl;
}
/* ===== */
if (!$cache) {
// Enforce cache loading
require_once $cfg['system_dir'] . '/cache.php';
$cache = new Cache();
$cache->init();
}
if ($a == 'purge' && $cache) {
if (cot_check_xg() && $cache->clear()) {
$db->update($db_users, array('user_auth' => ''), "user_auth != ''");
cot_message('adm_purgeall_done');
} else {
cot_error('Error');
}
} elseif ($a == 'delete') {
cot_check_xg();
$name = $db->prep(cot_import('name', 'G', 'TXT'));
$db->delete($db_cache, "c_name = '{$name}'") ? cot_message('adm_delcacheitem') : cot_error('Error');
}
if ($cache && $cache->mem) {
$info = $cache->get_info();