mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-12 19:39:10 +08:00
35 lines
856 B
PHP
35 lines
856 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,
|
|
'index' => $config->redis->index,
|
|
'persistent' => $config->redis->persistent,
|
|
]);
|
|
|
|
return $backend;
|
|
});
|
|
}
|
|
|
|
} |