bakaphp /
phalcon-api
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Gewaer\Providers; |
||
| 4 | |||
| 5 | use Phalcon\Di\ServiceProviderInterface; |
||
| 6 | use Phalcon\DiInterface; |
||
| 7 | use Redis; |
||
| 8 | use function Gewaer\Core\envValue; |
||
| 9 | |||
| 10 | class RedisProvider implements ServiceProviderInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param DiInterface $container |
||
| 14 | */ |
||
| 15 | 4 | public function register(DiInterface $container) |
|
| 16 | { |
||
| 17 | 4 | $container->setShared( |
|
| 18 | 4 | 'redis', |
|
| 19 | function () { |
||
| 20 | //Connect to redis |
||
| 21 | 1 | $redis = new Redis(); |
|
| 22 | 1 | $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), envValue('REDIS_PORT', 6379)); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 23 | 1 | $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); |
|
| 24 | 1 | return $redis; |
|
| 25 | 4 | } |
|
| 26 | ); |
||
| 27 | 4 | } |
|
| 28 | } |
||
| 29 |