redis 使用demo
This commit is contained in:
augustdai 2019-09-12 21:56:14 +08:00 committed by GitHub
parent afdf3f6e87
commit 3bfe0d9c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,11 +42,28 @@ return [
`hyperf/redis` 实现了 `ext-redis` 代理和连接池,用户可以直接使用\Redis客户端。
```php
<?php
$redis = $this->container->get(\Redis::class);
use ...
$result = $redis->keys('*');
class ...
{
protected $container;
// 通过在构造函数的参数上声明参数类型完成自动注入
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function index()
{
$redis = $this->container->get(\Redis::class);
$result = $redis->keys('*');
}
}
```