-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathredis.inc
More file actions
39 lines (36 loc) · 758 Bytes
/
redis.inc
File metadata and controls
39 lines (36 loc) · 758 Bytes
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
<?php
/**
* php -mod-redis test/generic functions
*/
/** ---------------------------------- Tests functions -------------------------------------------- */
function get_redis_object()
{
$cfg = array(
'host'=>'localhost',
'port'=>6379,
'database'=>2,
);
if (is_file('redis-conn.ini')){
$cfg=parse_ini_file('redis-conn.ini');
}
static $r=null;
if ($r===null)
if (class_exists("Redis")){
$r = new Redis;
if ($r->connect($cfg['host'], $cfg['port'])){
$r->swapdb(0, (int)$cfg['database']);
return $r;
}
}
return false;
}
function get_redis_version()
{
$r = get_redis_object();
if ($r){
$info = $r->info('server');
// print_r($info);
return $info['redis_version'];
}
return false;
}