Fix tests
This commit is contained in:
parent
352ebb4105
commit
181af86899
@ -31,13 +31,18 @@ class CacheManager implements CacheInterface {
|
|||||||
{
|
{
|
||||||
$config = $container->get('config');
|
$config = $container->get('config');
|
||||||
$driverConf = $config->get('cache_driver');
|
$driverConf = $config->get('cache_driver');
|
||||||
|
|
||||||
|
if (empty($driverConf))
|
||||||
|
{
|
||||||
|
$driverConf = 'SQLDriver';
|
||||||
|
}
|
||||||
|
|
||||||
$driverClass = __NAMESPACE__ . "\\Driver\\{$driverConf}";
|
$driverClass = __NAMESPACE__ . "\\Driver\\{$driverConf}";
|
||||||
$driver = new $driverClass($container);
|
$driver = new $driverClass($container);
|
||||||
|
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retreive a cached value if it exists, otherwise, get the value
|
* Retreive a cached value if it exists, otherwise, get the value
|
||||||
* from the passed arguments
|
* from the passed arguments
|
||||||
@ -50,18 +55,18 @@ class CacheManager implements CacheInterface {
|
|||||||
public function get($object, $method, array $args=[])
|
public function get($object, $method, array $args=[])
|
||||||
{
|
{
|
||||||
$hash = $this->generateHashForMethod($object, $method, $args);
|
$hash = $this->generateHashForMethod($object, $method, $args);
|
||||||
|
|
||||||
$data = $this->driver->get($hash);
|
$data = $this->driver->get($hash);
|
||||||
|
|
||||||
if (empty($data))
|
if (empty($data))
|
||||||
{
|
{
|
||||||
$data = call_user_func_array([$object, $method], $args);
|
$data = call_user_func_array([$object, $method], $args);
|
||||||
$this->driver->set($hash, $data);
|
$this->driver->set($hash, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retreive a fresh value from the method, and update the cache
|
* Retreive a fresh value from the method, and update the cache
|
||||||
* @param object $object - object to retrieve fresh value from
|
* @param object $object - object to retrieve fresh value from
|
||||||
|
Loading…
Reference in New Issue
Block a user