1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00
2020-04-08 16:42:36 +08:00

32 lines
766 B
PHP

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