Example #1
0
 /**
  * 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;
 }
Example #2
0
 protected function getFromCache($modelId)
 {
     if (!$this->cacheEnabled) {
         return null;
     }
     $cache = Cache::getCache();
     return $cache->get($this->modelName . '::' . $modelId, null);
 }
Example #3
0
 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')));
     }
 }