1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 22:01:38 +08:00
2019-12-13 00:10:10 +08:00

33 lines
746 B
PHP

<?php
namespace App\Providers;
use App\Library\Cache\Backend\Redis as RedisBackend;
use Phalcon\Cache\Frontend\Json as JsonFrontend;
class Cache extends AbstractProvider
{
protected $serviceName = 'cache';
public function register()
{
$this->di->setShared($this->serviceName, function () {
$config = $this->getShared('config');
$frontend = new JsonFrontend([
'lifetime' => $config->redis->lifetime,
]);
$backend = new RedisBackend($frontend, [
'host' => $config->redis->host,
'port' => $config->redis->port,
'auth' => $config->redis->auth,
]);
return $backend;
});
}
}