Lumen5.6 configuration redis

Lumen5.6 configuration redis

1. Installation redis expansion, the following two methods

1.1 .

composer require predis/predis
composer require illuminate/redis

1.2 (second written directly in composer.json)

"predis/predis": "^1.1",
"illuminate/redis": "^5.6.39"

Delete composer.lock

执行sudo composer clearcache 

然后sudo composer update

2. Introduction Redis support

In the directory bootstrap/app.phpyou want to expand the introduction of redis

$app->register(Illuminate\Redis\RedisServiceProvider::class);

3. Enable Redis Helper

Lumen Laravel and some do not like the default 'Facades' and 'Eloquent' is not enabled, to imagine laravel redis used as the file should bootstrap / app.php in the 'Facades' and 'Eloquent' of $ app-> withFacades () and $ app-> withEloquent () opens like a comment
 

4. Redis server configuration parameters

The default system is called .envin the redis configuration file, but generally after installation without these parameters, you can view the file path vendor/laravel/lumen-framework/config/database.phpin to see what parameters need to be configured, for example, my .envfile need to configure

IP = REDIS_HOST 
REDIS_PORT = 22188 
REDIS_PASSWORD = Redis password

5. Use Redis

Test redis

$redis = Redis::connection();
var_dump($redis);

 

 

Published 76 original articles · won praise 72 · views 70000 +

Guess you like

Origin blog.csdn.net/weixin_43713498/article/details/104987892