4
4
* @param mixed $prefix prefix
5
5
* @return void
6
6
*/
7
- function clearCacheData ($ prefix ='' ) {
8
- $ prefix =strtolower ($ prefix );
9
- /*
10
- $apcu_available = function_exists('apcu_enabled') && apcu_enabled();
11
- if ($apcu_available) {
12
- apcu_clear_cache();
13
- }
14
- */
7
+ function clearCacheData ($ prefix = '' )
8
+ {
9
+ $ prefix = strtolower ($ prefix );
15
10
if (defined ('USE_REDIS ' )) {
16
11
global $ redisConnection ;
17
12
if (!isset ($ redisConnection )) {
18
13
$ redisConnection = new Redis ();
19
14
$ redisConnection ->pconnect (USE_REDIS );
20
15
}
21
- if (!prefix)$ redisConnection ->flushDB ();
22
- else
23
- {
24
- $ list =$ redisConnection ->getKeys ($ prefix ."* " );
25
- foreach ($ list as $ key1 )
26
- $ redisConnection ->del ($ key1 );
27
- }
16
+ if (!$ prefix ) $ redisConnection ->flushDB ();
17
+ else {
18
+ $ list = $ redisConnection ->getKeys ($ prefix . "* " );
19
+ foreach ($ list as $ key1 )
20
+ $ redisConnection ->del ($ key1 );
21
+ }
28
22
return ;
29
23
}
30
- if (!$ prefix )SQLTruncateTable ('cached_values ' );
31
- else SQLExec ("delete from cached_values where KEYWORD like ' $ prefix%' " );
24
+ if (!$ prefix ) SQLTruncateTable ('cached_values ' );
25
+ else SQLExec ("delete from cached_values where KEYWORD like ' $ prefix%' " );
32
26
}
33
27
34
28
/**
35
29
* Return all Cache Data from prefix
36
30
* Summary of getAllCache
37
- * @param mixed $prefix
31
+ * @param mixed $prefix
38
32
* @return array
39
33
*/
40
- function getAllCache ($ prefix= '' )
34
+ function getAllCache ($ prefix = '' )
41
35
{
42
- $ prefix= strtolower ($ prefix );
43
- $ out= array ();
36
+ $ prefix = strtolower ($ prefix );
37
+ $ out = array ();
44
38
if (defined ('USE_REDIS ' )) {
45
39
global $ redisConnection ;
46
40
if (!isset ($ redisConnection )) {
47
41
$ redisConnection = new Redis ();
48
42
$ redisConnection ->pconnect (USE_REDIS );
49
43
}
50
- $ list =$ redisConnection ->getKeys ($ prefix ."* " );
51
- foreach ($ list as $ key1 )
52
- $ out [$ key1 ]=$ redisConnection ->get ($ key1 );
53
- }
54
- else $ out =SQLExec ("select * from cached_values where KEYWORD like ' $ prefix%' " );
44
+ $ list = $ redisConnection ->getKeys ($ prefix . "* " );
45
+ foreach ($ list as $ key1 )
46
+ $ out [$ key1 ] = $ redisConnection ->get ($ key1 );
47
+ } else $ out = SQLExec ("select * from cached_values where KEYWORD like ' $ prefix%' " );
55
48
return $ out ;
56
49
}
57
50
@@ -64,9 +57,9 @@ function getAllCache($prefix='')
64
57
*/
65
58
function saveToCache ($ key , $ value )
66
59
{
67
- $ key= strtolower ($ key );
60
+ $ key = strtolower ($ key );
68
61
if (is_array ($ value ) || strlen ($ value ) > 255 ) {
69
- SQLExec ("DELETE FROM cached_values WHERE KEYWORD=' " . $ key . "' " );
62
+ SQLExec ("DELETE FROM cached_values WHERE KEYWORD=' " . $ key . "' " );
70
63
return ;
71
64
}
72
65
@@ -80,7 +73,7 @@ function saveToCache($key, $value)
80
73
return ;
81
74
}
82
75
83
- $ rec = array ('KEYWORD ' => $ key , 'DATAVALUE ' => $ value );
76
+ $ rec = array ('KEYWORD ' => $ key , 'DATAVALUE ' => $ value );
84
77
$ sqlQuery = "REPLACE INTO cached_values (KEYWORD, DATAVALUE) " .
85
78
" VALUES (' " . DbSafe1 ($ rec ['KEYWORD ' ]) . "', " .
86
79
"' " . DbSafe1 ($ rec ['DATAVALUE ' ]) . "') " ;
@@ -94,7 +87,7 @@ function saveToCache($key, $value)
94
87
*/
95
88
function checkFromCache ($ key )
96
89
{
97
- $ key= strtolower ($ key );
90
+ $ key = strtolower ($ key );
98
91
if (defined ('USE_REDIS ' )) {
99
92
global $ redisConnection ;
100
93
if (!isset ($ redisConnection )) {
@@ -110,7 +103,7 @@ function checkFromCache($key)
110
103
}
111
104
112
105
113
- $ rec = SQLSelectOne ("SELECT * FROM cached_values WHERE KEYWORD = ' " . DBSafe ($ key ) . "' " );
106
+ $ rec = SQLSelectOne ("SELECT * FROM cached_values WHERE KEYWORD = ' " . DBSafe ($ key ) . "' " );
114
107
115
108
if (isset ($ rec ['KEYWORD ' ])) {
116
109
return $ rec ['DATAVALUE ' ];
@@ -177,7 +170,7 @@ function postToWebSocket($property, $value, $post_action = 'PostProperty')
177
170
}
178
171
}
179
172
180
- if (!Is_Object ($ wsClient ) && IsSet ($ _SERVER ['REQUEST_METHOD ' ])) {
173
+ if (!Is_Object ($ wsClient ) && isset ($ _SERVER ['REQUEST_METHOD ' ])) {
181
174
return false ;
182
175
}
183
176
@@ -208,7 +201,7 @@ function postToWebSocket($property, $value, $post_action = 'PostProperty')
208
201
}
209
202
}
210
203
211
- if (!$ data_sent && !IsSet ($ _SERVER ['REQUEST_METHOD ' ])) {
204
+ if (!$ data_sent && !isset ($ _SERVER ['REQUEST_METHOD ' ])) {
212
205
//reconnect
213
206
$ wsClient = new WebsocketClient ;
214
207
if ((@$ wsClient ->connect ('127.0.0.1 ' , WEBSOCKETS_PORT , '/majordomo ' ))) {
0 commit comments