コード例 #1
0
ファイル: Github.php プロジェクト: kukupigs/PHPCI
 /**
  * Get an array of repositories from Github's API.
  */
 public function getRepositories()
 {
     $token = Config::getInstance()->get('phpci.github.token');
     if (!$token) {
         die(json_encode(null));
     }
     $cache = Cache::getCache(Cache::TYPE_APC);
     $rtn = $cache->get('phpci_github_repos');
     if (!$rtn) {
         $orgs = $this->makeRequest('/user/orgs', array('access_token' => $token));
         $params = array('type' => 'all', 'access_token' => $token);
         $repos = array('user' => array());
         $repos['user'] = $this->makeRecursiveRequest('/user/repos', $params);
         foreach ($orgs as $org) {
             $repos[$org['login']] = $this->makeRecursiveRequest('/orgs/' . $org['login'] . '/repos', $params);
         }
         $rtn = array();
         foreach ($repos as $repoGroup) {
             foreach ($repoGroup as $repo) {
                 $rtn['repos'][] = $repo['full_name'];
             }
         }
         $cache->set('phpci_github_repos', $rtn);
     }
     return $rtn;
 }
コード例 #2
0
ファイル: Store.php プロジェクト: dw250100785/b8framework
 protected function getFromCache($modelId)
 {
     if (!$this->cacheEnabled) {
         return null;
     }
     $cache = Cache::getCache();
     return $cache->get($this->modelName . '::' . $modelId, null);
 }
コード例 #3
0
ファイル: CacheTest.php プロジェクト: dw250100785/b8framework
 public function testCaching()
 {
     $cache = b8\Cache::getInstance();
     if ($cache->isEnabled()) {
         $this->assertTrue($cache->set('anything', 10));
         $this->assertTrue($cache->get('anything') == 10);
         $this->assertTrue(is_null($cache->get('invalid')));
     }
 }