SecretCounterUtil.php
1.97 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
include './SecretContext.php';
include './iCache.php';
include '../../TopSdk.php';
class SecretCounterUtil
{
private $topClient ;
private $cacheClient = null;
private $counterMap;
function __construct($client)
{
$this->topClient = $client;
$counterMap = array();
}
/*
* 如果不走缓存模式,析构即调用API回传统计信息
*/
function __destruct()
{
if($this->cacheClient == null){
}
}
function report($session)
{
$request = new TopSdkFeedbackUploadRequest;
}
function setCacheClient($cache)
{
$this->cacheClient = $cache;
}
function incrDecrypt($delt,$session,$type)
{
$item = getItem($session);
if($item == null){
$item = new SecretCounter();
putItem($session,$item);
}
if($type == "nick"){
$item->$decryptNickNum += $delt;
}else if($type == "receiver_name"){
$item->$decryptReceiverNameNum += $delt ;
}else if($type == "phone"){
$item->$decryptPhoneNum += $delt ;
}else if($type == "simple"){
$item->$decryptSimpleNum += $delt ;
}
}
function incrEncrypt($delt,$session,$type)
{
$item = getItem($session);
if($item == null){
$item = new SecretCounter();
putItem($session,$item);
}
if($type == "nick"){
$item->$encryptNickNum += $delt ;
}else if($type == "receiver_name"){
$item->$encryptReceiverNameNum += $delt ;
}else if($type == "phone"){
$item->$encryptPhoneNum += $delt ;
}else if($type == "simple"){
$item->$encryptSimpleNum += $delt ;
}
}
function getItem($session)
{
if($this->cacheClient == null){
return $counterMap[$session];
}else{
return $this->cacheClient->getCache('s_'.$session);
}
}
function putItem($session,$item)
{
if($this->cacheClient == null){
$counterMap[$session] = $item;
}else{
$this->cacheClient->setCache('s_'.$session,$item);
}
}
}
?>