Laravel redis 連不同的連線

vimkid發表於2021-03-09

database.php

'redis' => [

  'client' => env('REDIS_CLIENT', 'phpredis'),

  'options' => [
  'cluster' => env('REDIS_CLUSTER', 'redis'),
  ],

  'default' => [
      'url' => env('REDIS_URL'),
      'host' => env('REDIS_HOST', '127.0.0.1'),
      'password' => env('REDIS_PASSWORD', 'null),
      'port' => env('REDIS_PORT', 6379),
      'database' => env('REDIS_DB', 0),
  ],
  'test [
      'url' => env('REDIS_URL'),
      'host' => env('REDIS_HOST', 'xx.xx.xx.xx')
      'password' => env('REDIS_PASSWORD', 'null),
      'port' => env('REDIS_PORT', 6379),
      'database' => env('REDIS_DB', 0),
  ],
]

呼叫

$redis = Redis::connection('test')
$redis->set('xx,'xx);
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章