-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemcached.php
More file actions
66 lines (57 loc) · 1.44 KB
/
memcached.php
File metadata and controls
66 lines (57 loc) · 1.44 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/* (C)2006-2021 FoundPHP Framework.
* name: Database Object
* weburl: http://www.FoundPHP.com
* mail: master@FoundPHP.com
* author: 孟大川
* version: v3.201212
* start: 2006-05-24
* update: 2020-12-12
* payment: Free 免费
* This is not a freeware, use is subject to license terms.
* 此软件为授权使用软件,请参考软件协议。
* http://www.foundphp.com/?m=agreement
*/
Class Dirver_memcached{
//连接数据库
function DBLink($dba=''){
if (class_exists('Memcached')==false){
return 2;
}
$this->LinkID = new Memcached();
$this->LinkID->addServer($dba['dbhost'],($dba['dbport']!=''?$dba['dbport']:11211));
return $this->LinkID;
}
//单条语句查询,默认先进先出
function query($name) {
$result = $this->LinkID->get($name);
return $result;
}
//插入语句
/*
name
$db->insert('key',array('val'=>'test','time'=>3600));
*/
function insert($name,$data=array()) {
if(is_array($data) && $data['val']!=''){
if($data['time']>0){
$this->LinkID->delete($name);
$query = $this->LinkID->set($name, $data['val'],$data['time']);
}else{
$this->LinkID->delete($name);
$query = $this->LinkID->set($name, $data['val']);
}
}
return array('query'=>$query);
}
//关闭当前数据库连接
function close(){
return $this->LinkID->quit();
}
//获得版本
function version(){
$version = $this->LinkID->getVersion();
return current($version);
}
}
?>