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


PHP Cache::load方法代码示例

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


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

示例1: render

 /**
  * Renders template to output.
  * @return void
  */
 public function render()
 {
     if ($this->file == NULL) {
         // intentionally ==
         throw new InvalidStateException("Template file name was not specified.");
     }
     $cache = new Cache($storage = $this->getCacheStorage(), 'Nette.FileTemplate');
     if ($storage instanceof PhpFileStorage) {
         $storage->hint = str_replace(dirname(dirname($this->file)), '', $this->file);
     }
     $cached = $compiled = $cache->load($this->file);
     if ($compiled === NULL) {
         try {
             $compiled = "<?php\n\n// source file: {$this->file}\n\n?>" . $this->compile();
         } catch (TemplateException $e) {
             $e->setSourceFile($this->file);
             throw $e;
         }
         $cache->save($this->file, $compiled, array(Cache::FILES => $this->file, Cache::CONSTS => 'Framework::REVISION'));
         $cached = $cache->load($this->file);
     }
     if ($cached !== NULL && $storage instanceof PhpFileStorage) {
         LimitedScope::load($cached['file'], $this->getParameters());
     } else {
         LimitedScope::evaluate($compiled, $this->getParameters());
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:31,代码来源:FileTemplate.php

示例2: setConnection

 public function setConnection(Connection $connection)
 {
     $this->connection = $connection;
     if ($this->cacheStorage) {
         $this->cache = new Cache($this->cacheStorage, 'Nette.Database.' . md5($connection->getDsn()));
         $this->structure = ($tmp = $this->cache->load('structure')) ? $tmp : $this->structure;
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:8,代码来源:DiscoveredReflection.php

示例3: create

 /**
  * Creates accessor for instances of given class.
  * @param string $class
  * @return Accessor
  */
 public function create($class)
 {
     $name = $this->naming->deriveClassName($class);
     $namespaced = $this->naming->getNamespace() . '\\' . $name;
     if (class_exists($namespaced) || $this->cache && $this->cache->load($name)) {
         return new $namespaced();
     }
     $definition = $this->generator->generate($class);
     if ($this->cache) {
         $this->cache->save($name, $definition);
     }
     eval($definition);
     return new $namespaced();
 }
开发者ID:markatom,项目名称:accessor,代码行数:19,代码来源:Factory.php

示例4: render

 /**
  * Renders template to output.
  * @return void
  */
 public function render()
 {
     $cache = new Cache($storage = $this->getCacheStorage(), 'Nette.Template');
     $cached = $compiled = $cache->load($this->source);
     if ($compiled === NULL) {
         $compiled = $this->compile();
         $cache->save($this->source, $compiled, array(Cache::CONSTS => 'Framework::REVISION'));
         $cached = $cache->load($this->source);
     }
     if ($cached !== NULL && $storage instanceof PhpFileStorage) {
         LimitedScope::load($cached['file'], $this->getParameters());
     } else {
         LimitedScope::evaluate($compiled, $this->getParameters());
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:19,代码来源:Template.php

示例5: get_content

    public function get_content()
    {
        $metric = $this->get_metric();
        $metric = Cache::load($this, 300);
        //5 minute cache for disk io
        $disk_io = array(array('Disk', 'Read(MB)', 'Write(MB)'));
        foreach ($metric['disk'] as $disk => $stat) {
            $disk_io[] = array($disk, $stat['read'], $stat['write']);
        }
        $disk_io = json_encode($disk_io);
        $cpu_io = json_encode(array(array('CPU Time', 'Percent'), array('IO Wait', $metric['cpu']['io_wait'])));
        echo <<<EOD
      <div id="widget_disk_io"></div>
      <div id="widget_cpu_io_wait"></div>
      <script type="text/javascript">
      google.load('visualization', '1', {packages:['gauge']});
      google.setOnLoadCallback(function () {
        var data = google.visualization.arrayToDataTable({$cpu_io});
        var goptions = {
          redFrom: 90, redTo: 100,
          yellowFrom:75, yellowTo: 90,
          minorTicks: 5
        };
        var chart = new google.visualization.Gauge(document.getElementById('widget_cpu_io_wait'));
        chart.draw(data, goptions);

        var data2 = google.visualization.arrayToDataTable({$disk_io});
        var chart2 = new google.visualization.ColumnChart(document.getElementById('widget_disk_io'));
        chart2.draw(data2, {});
      })        
    </script>
EOD;
    }
开发者ID:TheBillPleaseZA,项目名称:WordPress-Server-Dashboard,代码行数:33,代码来源:iostat.php

示例6: loadFromID

 public function loadFromID($id, $loadmeta = true, $loadelements = true)
 {
     // Loads content with given ID
     $cachekey = "content:id:" . $id;
     $content = Cache::load($cachekey);
     if (!isset($content['id'])) {
         // No cache found, load from database
         $sql = new SqlManager();
         // ...here server and language (both coming from controller if available) should be included!
         $sql->setQuery("SELECT * FROM content WHERE id={{id}}");
         $sql->bindParam("{{id}}", $id, "int");
         $content = $sql->result();
         if (!isset($content['id'])) {
             throw new Exception("No content for ID '{$id}' found!");
             return false;
         }
         $this->id = $content['id'];
         $this->data = $content;
         // Load other content data as well
         if ($loadmeta) {
             $this->data['meta'] = $this->loadMeta();
         }
         if ($loadelements) {
             $this->data['elements'] = $this->loadElements();
         }
         // Save cache for later
         Cache::save($cachekey, $this->data);
         Cache::save("content:url:" . $this->data['url'], $this->data);
     }
     return true;
 }
开发者ID:julianburr,项目名称:project-nutmouse,代码行数:31,代码来源:Content.php

示例7: get_content

    public function get_content()
    {
        $metric = $this->get_metric();
        $metric = Cache::load($this, 300);
        $data = array(array('Type', 'Used(MB)', 'Free(MB)'));
        foreach ($metric as $item) {
            if (empty($item)) {
                continue;
            }
            if ($item['type'] !== 'Mem' && $item['type'] !== 'Swap') {
                continue;
            }
            if (0 == $item['free'] + $item['used']) {
                continue;
            }
            $data[] = array($item['type'], $item['used'], $item['free']);
        }
        $data = json_encode($data);
        echo <<<EOD
      <div id="widget_ram_usage"></div>
      <script type="text/javascript">
      google.setOnLoadCallback(function () {
        var data = google.visualization.arrayToDataTable({$data});
        var options = {
          isStacked: true
        };
        var chart = new google.visualization.ColumnChart(document.getElementById('widget_ram_usage'));
        chart.draw(data, options);
      })        
    </script>
EOD;
    }
开发者ID:TheBillPleaseZA,项目名称:WordPress-Server-Dashboard,代码行数:32,代码来源:ram.php

示例8: _get_cats_tree

 function _get_cats_tree()
 {
     global $LANG, $CAT_ARTICLES;
     Cache::load('articles');
     if (!(isset($CAT_ARTICLES) && is_array($CAT_ARTICLES))) {
         $CAT_ARTICLES = array();
     }
     $ordered_cats = array();
     foreach ($CAT_ARTICLES as $id => $cat) {
         $cat['id'] = $id;
         $ordered_cats[numeric($cat['id_left'])] = array('this' => $cat, 'children' => array());
     }
     $level = 0;
     $cats_tree = array(array('this' => array('id' => 0, 'name' => $LANG['root']), 'children' => array()));
     $parent =& $cats_tree[0]['children'];
     $nb_cats = count($CAT_ARTICLES);
     foreach ($ordered_cats as $cat) {
         if ($cat['this']['level'] == $level + 1 && count($parent) > 0) {
             $parent =& $parent[count($parent) - 1]['children'];
         } elseif ($cat['this']['level'] < $level) {
             $j = 0;
             $parent =& $cats_tree[0]['children'];
             while ($j < $cat['this']['level']) {
                 $parent =& $parent[count($parent) - 1]['children'];
                 $j++;
             }
         }
         $parent[] = $cat;
         $level = $cat['this']['level'];
     }
     return $cats_tree[0];
 }
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:32,代码来源:articles_interface.class.php

示例9: fetchData

 /**
  * Fetch data.
  *
  * @param string $path
  * @param array $params
  * @param string $tag
  * @param int $cacheLifetime
  * @param bool $forceFetch
  * @return array|mixed
  */
 public function fetchData($path, $params = [], $tag = '', $cacheLifetime = 0, $forceFetch = false)
 {
     // Set default values.
     $this->code = 200;
     $this->message = '';
     $fetch = true;
     $data = Cache::load($this->prefix, $path, $params, $cacheLifetime);
     if (!$forceFetch && count($data) > 0) {
         $fetch = false;
     }
     if ($fetch) {
         // Build and request data.
         $this->url = $this->buildUrl($path, $params);
         try {
             $client = new \GuzzleHttp\Client();
             $result = $client->get($this->url);
             if ($result->getStatusCode() == 200) {
                 $data = json_decode($result->getBody(), true);
             }
         } catch (\Exception $e) {
             $this->code = $e->getCode();
             $this->message = $e->getMessage();
         }
         // Save cache.
         if ($cacheLifetime > 0) {
             Cache::save($this->prefix, $path, $params, $data);
         }
     }
     // Extract on tag.
     if ($tag != '' && isset($data[$tag])) {
         $data = $data[$tag];
     }
     return $data;
 }
开发者ID:mrcorex,项目名称:battlenet-api,代码行数:44,代码来源:Client.php

示例10: load

 public function load()
 {
     // Load config
     // Try from cache
     $cachekey = "config";
     if ($this->user) {
         $cachekey .= ":" . $this->user;
     }
     $this->config = Cache::load("config");
     if (!is_array($this->config) || $this->get('cache.active') != 1) {
         // Load config from database
         $sql = new SqlManager();
         if (!is_null($this->user)) {
             $sql->setQuery("SELECT * FROM config WHERE user_id = {{user}}");
             $sql->bindParam("{{user}}", $this->user);
         } else {
             $sql->setQuery("SELECT * FROM config WHERE user_id IS NULL");
         }
         $sql->execute();
         $this->config = array();
         while ($row = $sql->fetch()) {
             $this->config[$row['name']] = $row['value'];
         }
         if (!isset($this->config['cache.active']) || $this->config['cache.active'] != 1) {
             // If cache is deactivated, clear possible cache file
             Cache::clear($cachekey);
         } else {
             // If cache is activeated, save config for later use
             Cache::save($cachekey, $this->config);
         }
     }
 }
开发者ID:julianburr,项目名称:project-nutmouse,代码行数:32,代码来源:Config.php

示例11: getURLContents

 /**
  *
  */
 protected function getURLContents()
 {
     if (isset($this->cache) && !$this->refresh) {
         $contents = $this->cache->load('URLContents', $loaded);
         if ($loaded) {
             return $contents;
         }
     }
     $contents = $this->request->init()->process();
     if ($contents === FALSE) {
         throw new Exception('URL konnte nicht gelesen werden: ' . Code::varInfo($this->request->getURL()));
     }
     if (isset($this->cache)) {
         $this->cache->store('URLContents', $contents);
     }
     return $contents;
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:20,代码来源:RssReader.php

示例12: get_content

 public function get_content()
 {
     $cmds = Cache::load($this, 3600 * 24);
     $content = '';
     foreach ($cmds as $cmd => $info) {
         $content .= "<p><strong>{$cmd}</strong>&nbsp; {$info}</p>";
     }
     echo $content;
 }
开发者ID:TheBillPleaseZA,项目名称:WordPress-Server-Dashboard,代码行数:9,代码来源:software.php

示例13: get_jsapi_ticket

 public function get_jsapi_ticket()
 {
     $cache = new Cache();
     $TICKET = $cache->load('TICKET');
     if (empty($TICKET)) {
         $result = json_decode($this->send_post('v=v', 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=' . $this->get_token() . '&type=jsapi'));
         $cache->save('TICKET', $result->ticket, 7200);
     }
     return $cache->load('TICKET');
 }
开发者ID:phptian,项目名称:buick.agar.io,代码行数:10,代码来源:js.php

示例14: getTree

 public static function getTree($name, $levels = 1)
 {
     $cachekey = "assortment:tree:" . $name;
     $assortment = Cache::load($cachekey);
     if (!is_array($assortment)) {
         $assortment = self::load($name, null, 0, $levels);
         Cache::save($cachekey, $assortment);
     }
     return $assortment;
 }
开发者ID:julianburr,项目名称:project-nutmouse,代码行数:10,代码来源:Assortment.php

示例15: testLoadInvalidValueAtKey

 public function testLoadInvalidValueAtKey()
 {
     $redis1 = $this->getMockBuilder('\\Redis')->getMock();
     $redis1->method('get')->willReturn(false);
     $cache1 = new Cache($redis1, 'prefix');
     $this->assertEquals(false, $cache1->load('unchecked:key'));
     $redis2 = $this->getMockBuilder('\\Redis')->getMock();
     $redis2->method('get')->willReturn([]);
     $cache2 = new Cache($redis1, 'prefix');
     $this->assertEquals(false, $cache2->load('unchecked:key'));
 }
开发者ID:vicgarcia,项目名称:kaavii,代码行数:11,代码来源:CacheTest.php


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