Redis
Redis用法與數(shù)據(jù)庫(kù)類(lèi)似,例如 plugin/foo/config/redis.php
return [
'default' => [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 0,
],
'cache' => [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
],
];
使用時(shí)
use support\Redis;
Redis::connection('plugin.foo.default')->get('key');
Redis::connection('plugin.foo.cache')->get('key');
同樣的,如果想復(fù)用主項(xiàng)目的Redis配置
use support\Redis;
Redis::get('key');
// 假設(shè)主項(xiàng)目還配置了一個(gè)cache連接
Redis::connection('cache')->get('key');