1.安装Redis 的框架扩展
composer require hyperf/redis
2.配置.env文件
REDIS_HOST=127.0.0.1 REDIS_AUTH=Your secret REDIS_PORT=6379 REDIS_DB=0
3.配置redis.php文件
在项目/config/autoload/,新建一个redis.php文件,文件内容如下
<?php
return [
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'auth' => env('REDIS_AUTH', ''),
'port' => (int) env('REDIS_PORT', 6379),
'db' => (int) env('REDIS_DB', 0),
'cluster' => [
'enable' => (bool) env('REDIS_CLUSTER_ENABLE', false),
'name' => null,
'seeds' => [],
],
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60),
],
],
];
4.使用
<?php
use HyperfUtilsApplicationContext;
$container = ApplicationContext::getContainer();
$redis = $container->get(Redis::class);
$result = $redis->keys('*');
spring中常见注解描述
[转]外观模式
[转]策略模式
分布式事务实践
SpringBoot入门
服务器性能调优
kvm qemu内幕介绍
xen 保存快照的实现之 —— device model 状态保存
xen hypercall 的应用层实现
