/
redis.php
40 lines (35 loc) · 858 Bytes
/
redis.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use tpr\db\DbRedis;
$single_config = [
'host' => '127.0.0.1',
'auth' => '',
'port' => '6379',
'prefix' => 'redis:',
'timeout' => 60,
'database' => [
'default' => 0,
],
];
$cluster_config = [
'cluster_name' => null,
'hosts' => [
'127.0.0.1:6379',
],
'auth' => '',
'prefix' => 'redis:',
'timeout' => 1.5,
'read_timeout' => 1.5,
'persistent' => true,
'database' => [
'default' => 0,
],
];
$redisClient = DbRedis::init('con_name', $single_config);
//$redisClient = DbRedis::init('con_name', $cluster_config);
$redisInstance = $redisClient->redis();
$redisInstance->info();
//kv opt
$data = ['test_data'];
$redisClient->kv('key')->set($data);
$redisClient->kv('key')->exist();
$redisClient->kv('key')->get();