Replace cache to Symfony/Cache component.
This commit is contained in:
parent
4f865719fa
commit
1dc8acd263
14 changed files with 255 additions and 360 deletions
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace PHPCensor\Helper;
|
||||
|
||||
use b8\Cache;
|
||||
use b8\Config;
|
||||
use GuzzleHttp\Client;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
|
||||
/**
|
||||
* The Github Helper class provides some Github API call functionality.
|
||||
|
|
@ -26,10 +26,10 @@ class Github
|
|||
$response = $client->get(('https://api.github.com' . $url), [
|
||||
'query' => $params,
|
||||
]);
|
||||
|
||||
|
||||
$body = json_decode($response->getBody(), true);
|
||||
$headers = $response->getHeaders();
|
||||
|
||||
|
||||
foreach ($body as $item) {
|
||||
$results[] = $item;
|
||||
}
|
||||
|
|
@ -62,8 +62,8 @@ class Github
|
|||
return [];
|
||||
}
|
||||
|
||||
$cache = Cache::getCache(Cache::TYPE_APC);
|
||||
$rtn = $cache->get('php-censor-github-repos');
|
||||
$cache = new FilesystemCache('', 0, RUNTIME_DIR . 'cache');
|
||||
$rtn = $cache->get('php-censor.github-repos');
|
||||
|
||||
if (!$rtn) {
|
||||
$client = new Client();
|
||||
|
|
@ -90,7 +90,7 @@ class Github
|
|||
}
|
||||
}
|
||||
|
||||
$cache->set('php-censor-github-repos', $rtn);
|
||||
$cache->set('php-censor.github-repos', $rtn, 3600);
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
|
|
|
|||
|
|
@ -397,8 +397,8 @@ class BuildError extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
$cacheKey = 'Cache.Build.' . $key;
|
||||
$rtn = $this->cache->get($cacheKey, null);
|
||||
$cacheKey = 'php-censor.build-' . $key;
|
||||
$rtn = $this->cache->get($cacheKey);
|
||||
|
||||
if (empty($rtn)) {
|
||||
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
|
||||
|
|
|
|||
|
|
@ -181,8 +181,8 @@ class BuildMeta extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
$cacheKey = 'Cache.Build.' . $key;
|
||||
$rtn = $this->cache->get($cacheKey, null);
|
||||
$cacheKey = 'php-censor.build-' . $key;
|
||||
$rtn = $this->cache->get($cacheKey);
|
||||
|
||||
if (empty($rtn)) {
|
||||
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
|
||||
|
|
|
|||
|
|
@ -453,8 +453,8 @@ class Project extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
$cacheKey = 'Cache.ProjectGroup.' . $key;
|
||||
$rtn = $this->cache->get($cacheKey, null);
|
||||
$cacheKey = 'php-censor.project-group-' . $key;
|
||||
$rtn = $this->cache->get($cacheKey);
|
||||
|
||||
if (empty($rtn)) {
|
||||
$rtn = Factory::getStore('ProjectGroup', 'PHPCensor')->getById($key);
|
||||
|
|
@ -741,8 +741,8 @@ class Project extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
$cacheKey = 'Cache.ProjectEnvironments.' . $key;
|
||||
$rtn = $this->cache->get($cacheKey, null);
|
||||
$cacheKey = 'php-censor.project-environments-' . $key;
|
||||
$rtn = $this->cache->get($cacheKey);
|
||||
|
||||
if (empty($rtn)) {
|
||||
$store = $this->getEnvironmentStore();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue