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


PHP AF::cache方法代码示例

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


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

示例1: fillFromDatabase

 private static function fillFromDatabase()
 {
     $cacheID = "all_currencies";
     self::$_allCurrencies = AF::cache()->get($cacheID);
     if (!self::$_allCurrencies) {
         $db = self::$_msql = SafeMySQL::getInstance();
         $sql = "SELECT * FROM `currency`";
         self::$_allCurrencies = $db->getInd('currency_id', $sql);
         AF::cache()->set($cacheID, self::$_allCurrencies);
     }
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: getHtmlInfo

 public static function getHtmlInfo($db)
 {
     echo '<script>var count_sql_queries = "' . $db->getQueryCount() . '"</script>';
     echo '<div class="service_info"><div class="container">';
     echo '<div class="t1">';
     $format = "Execution time: %f second.";
     printf($format, self::$ScriptTime);
     echo '<br>Sql queries: <span id="count_sql_queries">' . $db->getQueryCount() . '</span> &nbsp;';
     $array = $db->getStats();
     if ($array) {
         echo ' &nbsp; <a href="javascript:serviceInfoQuerysDiv()">Show querys</a></div>';
     }
     echo '<div class="t2">';
     echo 'Memory consumption: ' . number_format(self::$totalMemory, 0, '.', ',') . ' bytes<br>';
     echo 'Peak memory usage: ' . number_format(self::$memoryPeak, 0, '.', ',') . ' bytes';
     $cacheStat = AF::cache()->stats();
     $pUse = ($cacheStat['cmd_get'] - $cacheStat['cmd_set']) * 100 / $cacheStat['cmd_get'];
     echo '</div><div class="t3">Use memcache: <b>' . round($pUse) . '% (' . $cacheStat['cmd_get'] . '/' . $cacheStat['cmd_set'] . ')</b><br><a href="javascript:serviceInfoCacheDiv()">Show memcache info</a></div>';
     echo '<div class="service_info_querys" style="display:none;">';
     if ($array) {
         $i = 1;
         foreach ($array as $value) {
             echo '<br>' . $i . '. Sql: <b>' . $value['query'] . '</b>. <br>Time: ' . $value['timer'];
             $i++;
         }
     }
     echo '<br><br><div class="ajax hide"><b>Ajax sql</b><div></div></div>';
     echo '</div>';
     echo '<div class="service_info_cache" style="display:none;">';
     foreach ($cacheStat as $key => $value) {
         if (isset(self::$_cacheInfo[$key])) {
             echo '<br>' . self::$_cacheInfo[$key] . ': <b>' . $value . '</b>';
         }
     }
     echo '</div></div>';
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例3: clearCache

 public function clearCache()
 {
     parent::clearCache();
     AF::cache()->delete('all_users_by_user_id');
 }
开发者ID:,项目名称:,代码行数:5,代码来源:

示例4:

<?php

@(include_once '../settings/autoload.php');
AF::cache()->flush();
echo 'done...';
开发者ID:,项目名称:,代码行数:5,代码来源:

示例5: findAllInArray

 public function findAllInArray($turn = false)
 {
     $result = null;
     if ($this->isCache) {
         $cacheID = $this->modelName . '_get_all_in_array';
         $result = AF::cache()->get($cacheID);
     }
     if (!$result) {
         // hack for Templates class
         if ($this->modelName == 'template') {
             $sql = "SELECT template_id, template_name, body_subject\n\t\t\t\t\tFROM ?n\n\t\t\t\t\tORDER BY ?s DESC";
         } else {
             $sql = "SELECT *\n\t\t\t\t\tFROM ?n\n\t\t\t\t\tORDER BY ?s DESC";
         }
         $pks = $this->getPrimaryField();
         if (!is_array($pks)) {
             $pks = array($pks);
         }
         $resultTemp = self::$_msql->getAll($sql, $this->tableName(), implode(',', $pks));
         $result = array();
         foreach ($resultTemp as $item) {
             $keysArray = array();
             foreach ($pks as $k) {
                 $keysArray[] = $item[$k];
             }
             $key = implode('_', $keysArray);
             $result[$key] = $item;
         }
         if ($this->isCache) {
             $data = serialize($result);
             if (strlen($data) < 1000000) {
                 AF::cache()->set($cacheID, $result);
             }
         }
     }
     if ($this->_isRestrictions) {
         $pks = $this->getPrimaryField();
         if (is_array($pks)) {
             $pks = implode('_', $pks);
         }
         $f = AF::userAccess()->getRestrictionBySearch($pks);
         if ($f) {
             foreach ($result as $k => $v) {
                 if (!in_array($k, $f[$pks])) {
                     unset($result[$k]);
                 }
             }
         }
     }
     return $turn ? array_reverse($result) : $result;
 }
开发者ID:,项目名称:,代码行数:51,代码来源:

示例6: cache

 public static function cache()
 {
     if (!self::$cache) {
         self::$cache = AFMemCache::getInstance(Config::get()->components->cache['host'], Config::get()->components->cache['port'], 0, Config::get()->prefix);
     }
     return self::$cache;
 }
开发者ID:,项目名称:,代码行数:7,代码来源:


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