本文整理汇总了PHP中GO::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP GO::cache方法的具体用法?PHP GO::cache怎么用?PHP GO::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GO
的用法示例。
在下文中一共展示了GO::cache方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasAlarm
public function hasAlarm()
{
//caching is required. We don't use the session because we need to close
//session writing when checking email accounts. Otherwise it can block the
//session to long.
if (\GO::cache() instanceof \GO\Base\Cache\None) {
return false;
}
$cached = \GO::cache()->get($this->_getCacheKey());
return $cached != $this->unseen && $this->unseen > 0;
}
示例2: getAllFileHandlers
/**
*
* @return Filehandler\FilehandlerInterface
*/
public static function getAllFileHandlers()
{
if (!isset(self::$fileHandlers)) {
self::$fileHandlers = \GO::cache()->get('files-file-handlers');
if (!self::$fileHandlers) {
$modules = \GO::modules()->getAllModules();
self::$fileHandlers = array();
foreach ($modules as $module) {
self::$fileHandlers = array_merge(self::$fileHandlers, $module->moduleManager->findClasses('filehandler'));
}
\GO::cache()->set('files-file-handlers', self::$fileHandlers);
}
}
return self::$fileHandlers;
}
示例3: _getAllFields
/**
* Returns all custom fields for this link type
*
* @param int $linkType
* @return PDOStatement
*/
private function _getAllFields()
{
//cache is cleared when a field is saved or deleted in Field::AfterSave and afterdelete
if (!isset(self::$cacheColumns[$this->extendsModel()])) {
$cacheKey = $this->getCacheKey();
if ($cached = \GO::cache()->get($cacheKey)) {
self::$attributeLabels[$this->extendsModel()] = $cached['attributeLabels'];
self::$cacheColumns[$this->extendsModel()] = $cached['columns'];
} else {
$findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*')->ignoreAcl()->joinRelation('category');
$findParams->getCriteria()->addCondition('extends_model', $this->extendsModel(), '=', 'category');
$stmt = \GO\Customfields\Model\Field::model()->find($findParams);
self::$cacheColumns[$this->extendsModel()] = \GO\Base\Db\Columns::getColumns($this);
self::$attributeLabels[$this->extendsModel()] = array();
while ($field = $stmt->fetch()) {
self::$attributeLabels[$this->extendsModel()][$field->columnName()] = $field->category->name . ':' . $field->name;
self::$cacheColumns[$this->extendsModel()][$field->columnName()]['customfield'] = $field;
self::$cacheColumns[$this->extendsModel()][$field->columnName()]['regex'] = $field->validation_regex;
self::$cacheColumns[$this->extendsModel()][$field->columnName()]['gotype'] = 'customfield';
self::$cacheColumns[$this->extendsModel()][$field->columnName()]['unique'] = $field->unique_values;
//Don't validate required on the server side because customfields tabs can be disabled.
//self::$cacheColumns[$this->extendsModel()][$field->columnName()]['required']=$field->required;
}
\GO::cache()->set($cacheKey, array('attributeLabels' => self::$attributeLabels[$this->extendsModel()], 'columns' => self::$cacheColumns[$this->extendsModel()]));
}
}
$this->columns = self::$cacheColumns[$this->extendsModel()];
}
示例4: render
public function render()
{
require_once \GO::modules()->site->path . 'widget/twitter/codebird.php';
$cacheKey = $this->consumerKey . ':' . $this->accessToken . ':' . $this->userTimeLine . ':' . $this->retweets;
if (!$this->cacheLifeTime || !($tweets = \GO::cache()->get($cacheKey))) {
//Get authenticated
\Codebird\Codebird::setConsumerKey($this->consumerKey, $this->consumerSecret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($this->accessToken, $this->accessTokenSecret);
//These are our params passed in
$params = array('screen_name' => $this->screenName, 'count' => $this->limit, 'include_rts' => $this->retweets, 'exclude_replies' => $this->exclude_replies);
//tweets returned by Twitter
$tweets = $this->userTimeLine ? (array) $cb->statuses_userTimeline($params) : (array) $cb->statuses_homeTimeline($params);
\GO::cache()->set($cacheKey, $tweets, $this->cacheLifeTime);
}
$html = '';
foreach ($tweets as $tweet) {
if (is_object($tweet)) {
$str = $this->template;
foreach ($tweet as $key => $value) {
if (!is_object($value)) {
if ($key == 'text') {
$value = \GO\Base\Util\String::text_to_html($value);
}
if ($key == 'created_at') {
$value = strtotime($value);
if ($value) {
$value = date('Y-m-d G:i', $value);
}
}
$str = str_replace('{' . $key . '}', $value, $str);
} else {
$value = (array) $value;
foreach ($value as $subKey => $subValue) {
if (is_string($subValue)) {
$str = str_replace('{' . $key . ':' . $subKey . '}', $subValue, $str);
}
}
}
}
$html .= $str;
}
}
return $html;
}
示例5: _clearColumnCache
/**
* GO caches the table schema for performance. We need to clear it
*/
private function _clearColumnCache()
{
//deleted cached column schema. See AbstractCustomFieldsRecord
\GO\Base\Db\Columns::clearCache(\GO::getModel(\GO::getModel($this->category->extends_model)->customfieldsModel()));
\GO::cache()->delete('customfields_' . $this->category->extends_model);
}
示例6: getColumns
/**
* Get all columns of a model
*
* @param ActiveRecord $model
* @return array
*/
public static function getColumns(ActiveRecord $model)
{
$tableName = $model->tableName();
$cacheKey = self::getCacheKey($model);
if (self::$forceLoad) {
unset(self::$_columns[$tableName]);
\GO::cache()->delete($cacheKey);
}
if (isset(self::$_columns[$tableName]) && !self::$forceLoad) {
return self::$_columns[$tableName];
} elseif ($columns = \GO::cache()->get($cacheKey)) {
// \GO::debug("Got columns from cache for $tableName");
self::$_columns[$tableName] = $columns;
return self::$_columns[$tableName];
} else {
// \GO::debug("Loading columns for $tableName");
self::$_columns[$tableName] = array();
$sql = "SHOW COLUMNS FROM `" . $tableName . "`;";
$stmt = $model->getDbConnection()->query($sql);
while ($field = $stmt->fetch()) {
preg_match('/([a-zA-Z].*)\\(([1-9].*)\\)/', $field['Type'], $matches);
if ($matches) {
$length = $matches[2];
$type = $matches[1];
} else {
$type = $field['Type'];
$length = 0;
}
$required = false;
$gotype = 'textfield';
$default = $field['Default'];
$ai = strpos($field['Extra'], 'auto_increment') !== false;
$pdoType = PDO::PARAM_STR;
switch ($type) {
case 'int':
case 'tinyint':
case 'bigint':
$pdoType = PDO::PARAM_INT;
if ($length == 1 && $type == 'tinyint') {
$gotype = 'boolean';
} else {
$gotype = '';
}
$length = 0;
$default = $ai || !isset($field['Default']) ? null : intval($default);
break;
case 'float':
case 'double':
case 'decimal':
$pdoType = PDO::PARAM_STR;
$length = 0;
$gotype = 'number';
$default = $default == null ? null : floatval($default);
break;
case 'mediumtext':
case 'longtext':
case 'text':
$gotype = 'textarea';
break;
case 'mediumblob':
case 'longblob':
case 'blob':
$gotype = 'blob';
break;
case 'date':
$gotype = 'date';
break;
case 'time':
$gotype = 'time';
break;
}
switch ($field['Field']) {
case 'ctime':
case 'mtime':
$gotype = 'unixtimestamp';
break;
case 'name':
$required = true;
break;
case 'user_id':
$gotype = 'user';
break;
}
//HACK: When a database may not be null and has no default value value is empty string
if (!GO::config()->debug) {
if ($field['Null'] == 'NO' && is_null($default) && !$ai) {
$default = '';
}
}
//workaround for old boolean fields as enums. Should be using bool now.
if ($type == "enum('0','1')") {
$gotype = 'boolean';
$default = '0';
}
//.........这里部分代码省略.........
示例7: clearCache
/**
* Clears the:
*
* 1. \GO::config()->cachedir folder. This folder contains mainly cached javascripts.
* 2. \GO\Base\Model objects cached in memory for a single script run
* 3. The permanent cache stored in \GO::cache()
*
*/
public static function clearCache()
{
\GO::config()->getCacheFolder(false)->delete();
\GO::cache()->flush();
\GO\Base\Model::clearCache();
}