1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 05:41:37 +08:00
2020-04-03 19:20:46 +08:00

34 lines
878 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,
'prefix' => $config->redis->prefix,
'persistent' => $config->redis->persistent,
]);
});
}
}