一,laravel默认会为缓存项添加前缀:
config/database.php中:
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
例子:
127.0.0.1:6379> keys *
1) "gs_database_ac_13866887788"
2) "a"
二,指定前缀:
在配置文件.env中指定REDIS_PREFIX即可,如图
查看效果:已生效
127.0.0.1:6379> keys *
1) "lhdac_13866887788"
2) "a"
标签:laravel,缓存,database,0.1,redis,REDIS,6379,env From: https://www.cnblogs.com/architectforest/p/18318044