Replace cache to Symfony/Cache component.
This commit is contained in:
parent
4f865719fa
commit
1dc8acd263
|
@ -1,7 +1,9 @@
|
|||
/vendor
|
||||
/composer.phar
|
||||
/runtime
|
||||
|
||||
/app/config.yml
|
||||
/public/assets/vendor
|
||||
|
||||
/public/artifacts
|
||||
!/public/artifacts/.gitkeep
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"symfony/debug": "~3.4.0",
|
||||
"symfony/dependency-injection": "~3.4.0",
|
||||
"symfony/event-dispatcher": "~3.4.0",
|
||||
"symfony/cache": "~3.4.0",
|
||||
"psr/log": "~1.0.0",
|
||||
"monolog/monolog": "~1.22.0",
|
||||
"pimple/pimple": "~3.0.0",
|
||||
|
@ -94,6 +95,9 @@
|
|||
"mremi/flowdock": "For FlowdockNotify plugin"
|
||||
},
|
||||
"extra": {
|
||||
"platform": {
|
||||
"php": "5.6.*"
|
||||
},
|
||||
"installer-paths": {
|
||||
"public/assets/vendor/sprintf-js": ["npm-asset/sprintf-js"],
|
||||
"public/assets/vendor/codemirror": ["npm-asset/codemirror"],
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "68c69d9aed8a6c9ef73856c6ddc9ab23",
|
||||
"content-hash": "acf206f49431b95f0fadc3a765e6930a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "behat/gherkin",
|
||||
|
@ -1602,16 +1602,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "5.7.26",
|
||||
"version": "5.7.27",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd"
|
||||
"reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd",
|
||||
"reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
|
||||
"reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1635,7 +1635,7 @@
|
|||
"sebastian/global-state": "^1.1",
|
||||
"sebastian/object-enumerator": "~2.0",
|
||||
"sebastian/resource-operations": "~1.0",
|
||||
"sebastian/version": "~1.0.3|~2.0",
|
||||
"sebastian/version": "^1.0.6|^2.0.1",
|
||||
"symfony/yaml": "~2.1|~3.0|~4.0"
|
||||
},
|
||||
"conflict": {
|
||||
|
@ -1680,7 +1680,7 @@
|
|||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-12-17T06:14:38+00:00"
|
||||
"time": "2018-02-01T05:50:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
|
@ -1787,6 +1787,52 @@
|
|||
],
|
||||
"time": "2015-09-11T15:10:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/cache.git",
|
||||
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Cache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for caching libraries",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"psr",
|
||||
"psr-6"
|
||||
],
|
||||
"time": "2016-08-06T20:24:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "1.0.0",
|
||||
|
@ -1933,6 +1979,54 @@
|
|||
],
|
||||
"time": "2016-10-10T12:19:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24",
|
||||
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"time": "2017-01-02T13:31:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "robmorgan/phinx",
|
||||
"version": "v0.8.1",
|
||||
|
@ -2880,6 +2974,76 @@
|
|||
"homepage": "https://symfony.com",
|
||||
"time": "2018-01-03T07:37:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/cache",
|
||||
"version": "v3.4.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/cache.git",
|
||||
"reference": "8dee9ec2c9824c3f4039960d679a6689ee1cbdc1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/cache/zipball/8dee9ec2c9824c3f4039960d679a6689ee1cbdc1",
|
||||
"reference": "8dee9ec2c9824c3f4039960d679a6689ee1cbdc1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"psr/cache": "~1.0",
|
||||
"psr/log": "~1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"symfony/polyfill-apcu": "~1.1"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/var-dumper": "<3.3"
|
||||
},
|
||||
"provide": {
|
||||
"psr/cache-implementation": "1.0",
|
||||
"psr/simple-cache-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cache/integration-tests": "dev-master",
|
||||
"doctrine/cache": "~1.6",
|
||||
"doctrine/dbal": "~2.4",
|
||||
"predis/predis": "~1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Cache\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Cache component with PSR-6, PSR-16, and tags",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"caching",
|
||||
"psr6"
|
||||
],
|
||||
"time": "2018-01-18T22:16:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"version": "v3.4.4",
|
||||
|
@ -3409,17 +3573,73 @@
|
|||
"time": "2018-01-03T07:37:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.6.0",
|
||||
"name": "symfony/polyfill-apcu",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
|
||||
"url": "https://github.com/symfony/polyfill-apcu.git",
|
||||
"reference": "e8ae2136ddb53dea314df56fcd88e318ab936c00"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
||||
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/e8ae2136ddb53dea314df56fcd88e318ab936c00",
|
||||
"reference": "e8ae2136ddb53dea314df56fcd88e318ab936c00",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Apcu\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting apcu_* functions to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"apcu",
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2018-01-30T19:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b",
|
||||
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3431,7 +3651,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.6-dev"
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -3465,7 +3685,7 @@
|
|||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2017-10-11T12:05:26+00:00"
|
||||
"time": "2018-01-30T19:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace b8;
|
||||
|
||||
class Cache
|
||||
{
|
||||
const TYPE_APC = 'ApcCache';
|
||||
const TYPE_REQUEST = 'RequestCache';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $instance = [];
|
||||
|
||||
/**
|
||||
* Get a cache object of a specified type.
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getCache($type = self::TYPE_REQUEST)
|
||||
{
|
||||
if (!isset(self::$instance[$type])) {
|
||||
$class = '\\b8\\Cache\\' . $type;
|
||||
self::$instance[$type] = new $class();
|
||||
}
|
||||
|
||||
return self::$instance[$type];
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Cache;
|
||||
|
||||
use b8\Type;
|
||||
|
||||
class ApcCache implements Type\CacheInterface
|
||||
{
|
||||
/**
|
||||
* Check if caching is enabled.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
$rtn = false;
|
||||
$apcCli = ini_get('apc.enable_cli');
|
||||
|
||||
if (function_exists('apc_fetch') && (php_sapi_name() != 'cli' || in_array($apcCli, ['1', 1, true, 'On']))) {
|
||||
$rtn = true;
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item from the cache:
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
$rtn = apc_fetch($key, $success);
|
||||
if (!$success) {
|
||||
$rtn = $default;
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the cache:
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param integer $ttl
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function set($key, $value = null, $ttl = 0)
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return apc_store($key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache:
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool|string[]
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return apc_delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item is in the cache:
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool|string[]
|
||||
*/
|
||||
public function contains($key)
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return apc_exists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short-hand syntax for get()
|
||||
*
|
||||
* @see Config::get()
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short-hand syntax for set()
|
||||
*
|
||||
* @see Config::set()
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function __set($key, $value = null)
|
||||
{
|
||||
return $this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is set
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool|string[]
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->contains($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
$this->delete($key);
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Cache;
|
||||
|
||||
use b8\Type;
|
||||
|
||||
class RequestCache implements Type\CacheInterface
|
||||
{
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Check if caching is enabled.
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item from the cache:
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return $this->contains($key) ? $this->data[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the cache:
|
||||
*/
|
||||
public function set($key, $value = null, $ttl = 0)
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache:
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
if ($this->contains($key)) {
|
||||
unset($this->data[$key]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item is in the cache:
|
||||
*/
|
||||
public function contains($key)
|
||||
{
|
||||
return array_key_exists($key, $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short-hand syntax for get()
|
||||
* @see Config::get()
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short-hand syntax for set()
|
||||
* @see Config::set()
|
||||
*/
|
||||
public function __set($key, $value = null)
|
||||
{
|
||||
return $this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is set
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->contains($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
$this->delete($key);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace b8;
|
||||
|
||||
use b8\Exception\HttpException;
|
||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
|
||||
class Model
|
||||
{
|
||||
|
@ -23,7 +24,7 @@ class Model
|
|||
$this->data = array_merge($this->data, $initialData);
|
||||
}
|
||||
|
||||
$this->cache = Cache::getCache(Cache::TYPE_REQUEST);
|
||||
$this->cache = new ArrayCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Type;
|
||||
|
||||
interface CacheInterface
|
||||
{
|
||||
public function get($key, $default = null);
|
||||
|
||||
public function set($key, $value = null, $ttl = 0);
|
||||
|
||||
public function delete($key);
|
||||
|
||||
public function contains($key);
|
||||
|
||||
public function isEnabled();
|
||||
|
||||
public function __get($key);
|
||||
|
||||
public function __set($key, $value = null);
|
||||
|
||||
public function __unset($key);
|
||||
|
||||
public function __isset($key);
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\b8;
|
||||
|
||||
use b8\Config, b8\Cache;
|
||||
|
||||
class CacheTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCreateSingleton()
|
||||
{
|
||||
$cache = Cache::getCache(Cache::TYPE_APC);
|
||||
self::assertInstanceOf('\b8\Cache\ApcCache', $cache);
|
||||
}
|
||||
|
||||
public function testDisableCaching()
|
||||
{
|
||||
$config = new Config();
|
||||
Config::getInstance()->set('DisableCaching', true);
|
||||
|
||||
$cache = Cache::getCache(Cache::TYPE_APC);
|
||||
$this->assertFalse($cache->isEnabled());
|
||||
$this->assertFalse($cache->set('anything', 10));
|
||||
$this->assertTrue(is_null($cache->get('anything')));
|
||||
|
||||
Config::getInstance()->set('DisableCaching', false);
|
||||
}
|
||||
|
||||
public function testCaching()
|
||||
{
|
||||
$cache = Cache::getCache(Cache::TYPE_APC);
|
||||
|
||||
if ($cache->isEnabled()) {
|
||||
$this->assertTrue($cache->set('anything', 10));
|
||||
$this->assertTrue($cache->get('anything') == 10);
|
||||
$this->assertTrue(is_null($cache->get('invalid')));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue