-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemcache_connect.php
36 lines (33 loc) · 1.12 KB
/
memcache_connect.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
<?php
if (extension_loaded('memcached')) {
$cache = new \Memcached();
$cache->addServer('localhost', 11222, true);
////////////////////
//for staging only//
///////////////////
$cache->get("@@test_admin_kv_data");
$key_prefix = 'staging_';
///////////////////////
//for production only//
//////////////////////
//$cache->get("@@admin_kv_data");
//$key_prefix = '';
}
function get_cost_appr_settings() {
if (extension_loaded('memcached')) {
$cache = $GLOBALS['cache'];
$key_prefix = $GLOBALS['key_prefix'];
$auto_approve = intval($cache->get($key_prefix . 'auto_approve'));
$auto_cost = intval($cache->get($key_prefix . 'auto_cost'));
} else {
$costApprQry = "SELECT * from `admin_settings`";
$result = mysqli_query($GLOBALS['db'], $costApprQry);
$costApprSettings = mysqli_fetch_assoc($result);
$auto_approve = intval($costApprSettings['auto_approve']);
$auto_cost = intval($costApprSettings['auto_cost']);
}
return array(
'auto_approve' => $auto_approve,
'auto_cost' => $auto_cost,
);
}