当前位置: 首页>>代码示例>>PHP>>正文


PHP App::cache方法代码示例

本文整理汇总了PHP中App::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP App::cache方法的具体用法?PHP App::cache怎么用?PHP App::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::cache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cache

 /**
  * @return ACache
  */
 public static function cache()
 {
     if (self::$cache === null) {
         self::$cache = new ACache();
     }
     return self::$cache;
 }
开发者ID:hhz1084,项目名称:pyz,代码行数:10,代码来源:App.class.php

示例2: tearDown

 public function tearDown()
 {
     // Empty cache
     foreach ($this->_transactionIds as $transactionId) {
         \App::cache()->remove($transactionId);
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:7,代码来源:AsyncServiceTest.php

示例3: clean

 public function clean($tags = array())
 {
     if ($this->_lifetime < 1) {
         return $this;
     }
     $tags = $this->_createCacheTags($tags);
     \App::log()->info("Cleaning " . $this->_itemClass . " cache. Tags: " . implode(', ', $tags));
     \App::cache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, $tags);
     return $this;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:10,代码来源:MapperCache.php

示例4: loadAcl

function loadAcl($files, $namespace, $format = 'yaml', $drop = false)
{
    if ($drop) {
        dropNamespace($namespace);
    }
    $class = "App_Acl_Loader_" . ucfirst($format);
    $loader = new $class();
    \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
    $loader->loadFromMultiFiles($files, $namespace);
    \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:11,代码来源:aclLoader.php

示例5: getTableColumns

 /**
  * 缓存并返回一个表的所有字段
  * 
  * @param mixed $table_name
  * @param mixed $db_name
  * @param bool $use_cache
  * @return Array
  */
 public function getTableColumns($table_name, $db_name, $use_cache = true)
 {
     $key = __METHOD__ . $db_name . $table_name;
     if (!isset(self::$colums[$key])) {
         $cache_data = App::cache($key);
         if (!$cache_data || !$use_cache) {
             $cache_data = $this->db->usedb($db_name)->getColumns($table_name);
             App::cache($key, $cache_data);
         }
         self::$colums[$key] = $cache_data;
     }
     return self::$colums[$key];
 }
开发者ID:laiello,项目名称:php-simple-webgame-framework,代码行数:21,代码来源:Model.class.php

示例6: json2Acl

function json2Acl($db, $ns, $file, $drop = false)
{
    $collection = "acl_" . $ns;
    $f = file_get_contents($file, 'r');
    if (!$f) {
        \App::log()->notice("Error to load file. Skiping {$ns}...");
        return;
    }
    //decoding json file
    $json_a = Zend_Json_Decoder::decode($f);
    if ($drop) {
        echo "\nDrop {$collection} from " . APPLICATION_ENV . " env \n";
        $db->{$collection}->drop();
    }
    foreach ($json_a as $element) {
        $db->{$collection}->save($element);
    }
    \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:19,代码来源:aclRestore.php

示例7: build

 /**
  * Build the Less file
  *
  * @param string $dest      The destination CSS file
  * @param bool   $force     If set to true, will build whereas the cache status
  * @param array  $variables Less variables to set before compiling the Less file
  */
 public function build($dest, $force = false, $variables = array())
 {
     if (!is_dir(dirname($dest))) {
         mkdir(dirname($dest), 0755, true);
     }
     $compiler = new \lessc();
     $lastCompilationFile = App::cache()->getCacheFilePath($this->getLastCompilationInfoFilename());
     if (!$force && is_file($lastCompilationFile)) {
         $cache = (include $lastCompilationFile);
     } else {
         $cache = $this->source;
     }
     $compiler->setFormatter('compressed');
     $compiler->setPreserveComments(false);
     $compilation = $compiler->cachedCompile($cache, $force);
     if (!is_array($cache) || $compilation['updated'] > $cache['updated']) {
         file_put_contents($dest, '/*** ' . date('Y-m-d H:i:s') . ' ***/' . PHP_EOL . $compilation['compiled']);
         $event = new Event('built-less', array('source' => $this->source, 'dest' => $dest));
         $event->trigger();
         // Save the compilation information
         unset($compilation['compiled']);
         $this->saveLastCompilationInfo($compilation);
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:31,代码来源:Less.php

示例8: setUp

 public function setUp()
 {
     \App::cache()->clean();
     $this->simMapper = SimMapper::getInstance();
     $this->_user = $this->_createAuthUser(array('userName' => 'SimUserTest', 'organizationId' => Application\Model\Organization\OrgServiceProviderModel::ORG_TYPE . '-' . 'sp1 (non-commercial)111111111111'));
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:6,代码来源:SimMapperEricssonIntTest.php

示例9: load

 /**
  * Load a language file
  *
  * @param string $plugin   The plugin to load
  * @param string $language The language to get the translations in
  * @param string $force    If set to true, force to reload the translations
  */
 private static function load($plugin, $language = LANGUAGE, $force = false)
 {
     if (!isset(self::$keys[$plugin][$language]) || $force || $language !== self::$usedLanguage) {
         App::logger()->debug('Reload keys for plugin ' . $plugin . ' and for language ' . $language);
         self::$keys[$plugin][$language] = array();
         $instance = new self($plugin, self::DEFAULT_LANGUAGE);
         $instance->build();
         self::$keys[$plugin][$language] = App::cache()->includeCache($instance->cacheFile);
         if ($language !== self::DEFAULT_LANGUAGE) {
             $instance = new self($plugin, $language);
             $instance->build();
             $translations = App::cache()->includeCache($instance->cacheFile);
             if (!is_array($translations)) {
                 $translations = array();
             }
             self::$keys[$plugin][$language] = array_merge(self::$keys[$plugin][$language], $translations);
         }
         self::$usedLanguage = $language;
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:27,代码来源:Lang.php

示例10: updateHawk

 /**
  * Update Hawk
  */
 public function updateHawk()
 {
     try {
         $api = new HawkApi();
         $nextVersions = $api->getCoreAvailableUpdates();
         if (empty($nextVersions)) {
             throw new \Exception("No newer version is available for Hawk");
         }
         // Update incrementally all newer versions
         foreach ($nextVersions as $version) {
             // Download the update archive
             $archive = $api->getCoreUpdateArchive($version['version']);
             // Extract the downloaded file
             $zip = new \ZipArchive();
             if ($zip->open($archive) !== true) {
                 throw new \Exception('Impossible to open the zip archive');
             }
             $zip->extractTo(TMP_DIR);
             // Put all modified or added files in the right folder
             $folder = TMP_DIR . 'update-v' . $version['version'] . '/';
             App::fs()->copy($folder . 'to-update/*', ROOT_DIR);
             // Delete the files to delete
             $toDeleteFiles = explode(PHP_EOL, file_get_contents($folder . 'to-delete.txt'));
             foreach ($toDeleteFiles as $file) {
                 if (is_file(ROOT_DIR . $file)) {
                     unlink(ROOT_DIR . $file);
                 }
             }
             // Remove temporary files and folders
             App::fs()->remove($folder);
             App::fs()->remove($archive);
         }
         // Execute the update method if exist
         $updater = new HawkUpdater();
         $methods = get_class_methods($updater);
         foreach ($nextVersions as $version) {
             $method = 'v' . str_replace('.', '_', $version['version']);
             if (method_exists($updater, $method)) {
                 $updater->{$method}();
             }
         }
         App::cache()->clear('views');
         App::cache()->clear('lang');
         App::cache()->clear(Autoload::CACHE_FILE);
         App::cache()->clear(Lang::ORIGIN_CACHE_FILE);
         $response = array('status' => true);
     } catch (\Exception $e) {
         $response = array('status' => false, 'message' => DEBUG_MODE ? $e->getMessage() : Lang::get('admin.update-hawk-error'));
     }
     App::response()->setContentType('json');
     return $response;
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:55,代码来源:AdminController.php

示例11: realpath

#!/usr/bin/env php
<?php 
/**
 * Script to flush cache
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli();
try {
    \App::cache()->clean();
    echo "Cache flushed \n";
} catch (Exception $e) {
    echo 'AN ERROR HAS OCCURRED:' . PHP_EOL;
    echo $e->getMessage() . PHP_EOL;
    exit(1);
}
// generally speaking, this script will be run from the command line
exit(0);
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:17,代码来源:flushCache.php

示例12: init

 public static function init()
 {
     if (self::$is_inited) {
         return true;
     }
     /** 载入基本配置 **/
     $app_config = self::loadConfig();
     $default_config = (require FRAME_PATH . '/config/default.php');
     self::$config = array_merge($default_config, $app_config);
     /** 初始化缓存信息 **/
     self::$cache = self::getInstance(ucfirst(self::$config['cache_type']) . 'Cache');
     /** 初始化DB配置及连接 **/
     foreach (self::$config['db_source'] as $key => $val) {
         /** 通过URL方式配置获得[scheme],[user],[pass],[host],[port]索引变量 **/
         $val = parse_url($val);
         self::$db[$key] = self::getInstance(ucfirst($val['scheme']) . 'Db');
         self::$db[$key]->init($val, self::$config['db_charset']);
         self::$config['db.' . $key] = $val;
         if (self::$db_default === false) {
             self::$db_default = $key;
         }
     }
     self::$input = self::getInstance('AppInput');
     self::$output = self::getInstance('AppOutput');
     /** 处理当前请求类型 **/
     if (isset($_SERVER["CONTENT_TYPE"]) && $_SERVER['CONTENT_TYPE'] == 'application/x-amf') {
         self::$model = 'amf';
     }
     /** 进行输入处理 **/
     if (self::$model == 'text') {
         $argv = $_SERVER['argv'];
         $script = array_shift($argv);
         parse_str(implode('&', $argv), $args);
         $args['script'] = $script;
         self::in($args);
     } else {
         $uri = self::getInstance('URI');
         $data_array = array_merge($_GET, $_POST, $uri->getVars());
         self::in($data_array);
         /*
         foreach( $data_array as $key=>$val ) {
             self::$input->$key = self::addslash($val);
         }
         */
         unset($_GET, $_POST);
     }
     if (!empty(self::$config['session_start'])) {
         session_start();
     }
     self::$is_inited = true;
 }
开发者ID:laiello,项目名称:php-simple-webgame-framework,代码行数:51,代码来源:App.class.php

示例13: _getListGroupsSimType

 protected function _getListGroupsSimType(PB\Inventory\ListQuery $req)
 {
     $status = array(PB\SimType::GLOBALTYPE => 'GLOBAL', PB\SimType::LOCALTYPE => 'LOCAL');
     $maxFirstPage = $req->getGroupsWithFirstPage() !== null ? $req->getGroupsWithFirstPage() : 5;
     $response = new PB\Inventory\ListQuery\Response();
     $result = new PB\Result();
     $response->setResult($result);
     if ($req->getFilter() === null) {
         $filterMess = new PB\Inventory\ListQuery\Filter();
     } else {
         $filterMess = $req->getFilter();
     }
     try {
         foreach ($status as $state => $label) {
             $auxReq = clone $req;
             $criteria = new Criteria();
             $criteria->setType(Criteria\Type::SIM_TYPE);
             $criteria->setSimType($state);
             $criteria->setReverse(false);
             $auxReq->setFilter(clone $filterMess);
             $auxReq->getFilter()->addCriterias($criteria);
             $sims = $this->_listSims($auxReq);
             $data = new PB\Inventory\ListQuery\Response\Data();
             $cacheData = $auxReq->serialize();
             $cacheId = uniqid();
             \App::cache()->save($cacheData, 'mock' . $cacheId, array(), $req->getQueryPaging()->getMaxTimeout());
             $data->setHandler($cacheId);
             $data->setDescription($label);
             $result->setCode(0);
             $result->setReason('Ok');
             $data->setRowCounter($sims->count());
             if ($maxFirstPage > 0) {
                 while ($sims->hasNext()) {
                     $sims->getNext();
                     $sim = $sims->current();
                     $sim['id'] = $sim['_id'];
                     unset($sim['_id']);
                     $row = new PB\Inventory\Row();
                     $row->parse($sim, new \DrSlump\Protobuf\Codec\PhpArray());
                     $data->addPage($row);
                 }
             }
             $maxFirstPage--;
             $response->addData($data);
         }
     } catch (Exception $e) {
         \App::log()->WARN($e);
         $result->setCode(1);
         $result->setReason($e->getMessage());
     }
     return $response;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:52,代码来源:SimEricssonMock.php

示例14: define

/**
 * @var MongoCollection
 */
$db = $cli->getResource('mongo');
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl'));
try {
    $env = $cli->getOption('e');
    $drop = $cli->getOption('d') ? true : false;
    $f = file_get_contents(DEFAULT_ACL_BASEPATH . "/build/acl_out.json", 'r');
    if (!$f) {
        throw new Exception("Error to load file \n");
    }
    //decoding json file
    $json_a = Zend_Json_Decoder::decode($f);
    if ($drop) {
        echo "\nDrop acl_portal from " . $env . " env \n";
        $db->acl_portal->drop();
    }
    foreach ($json_a as $element) {
        $db->acl_portal->insert($element);
    }
    \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
    echo "JSON data to mongo collection acl_portal ..OK \n\n";
} catch (Exception $e) {
    echo 'AN ERROR HAS OCCURRED:' . PHP_EOL;
    echo $e->getMessage() . PHP_EOL;
    echo $cli->getUsageMessage();
    exit(1);
}
// generally speaking, this script will be run from the command line
exit(0);
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:json2mongo.php

示例15: getAction

 /**
  * Get an specific sim by its Id
  */
 public function getAction()
 {
     $id = $this->getRequest()->getParam('id');
     $idType = $this->getRequest()->getParam('idType');
     if ($this->getRequest()->getParam('_avoidCache', false)) {
         \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Sim', $id));
     }
     if ($idType) {
         $sim = $this->_simSrv->load($id, \App::getOrgUserLogged(), $idType);
     } else {
         $sim = $this->_simSrv->load($id, \App::getOrgUserLogged());
     }
     if (empty($sim)) {
         throw new NotFoundException("Sim {$id} not found");
     }
     // Check if it's allowed to perform this action
     $this->_helper->checkSimReadPermissions($sim);
     try {
         $this->_helper->allowed('read_alarm_sim_detail', $sim);
         // Add alarms list to sim response (depends on alarm permissions)
         $this->_addAlarms($sim);
     } catch (\Application\Exceptions\ForbiddenException $e) {
         $sim->setAlarms(null);
     }
     $this->view->data = $sim;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:29,代码来源:SimController.php


注:本文中的App::cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。