本文整理汇总了PHP中tools::readCache方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::readCache方法的具体用法?PHP tools::readCache怎么用?PHP tools::readCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::readCache方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get($name = null, $auction_id = null, $cache = true)
{
$db = Database::getInstance();
if ($cache == true) {
$setting = tools::readCache($name . '_setting');
if (!empty($setting)) {
return $setting;
} else {
$setting = $db->getRow("SELECT value FROM " . DB_PREFIX . "settings WHERE name = '{$name}'");
if (!empty($setting)) {
return $setting['value'];
} else {
return false;
}
}
}
$increments = $db->getRow("SELECT * FROM " . DB_PREFIX . "increments WHERE auction_id = {$auction_id}");
return $increments[$name];
}
示例2: SUM
$bid_histories_result[] = $bid_history;
}
$result['Histories'] = $bid_histories_result;
}
}
$result['Auction'] = $auction;
// writing data to the application cache
if (!empty($_GET['histories'])) {
$auction = tools::writeCache('auction_view_' . $value, $result);
} else {
$auction = tools::writeCache('auction_' . $value, $result);
}
}
$result['User_id'] = $user_id;
if (!empty($user_id)) {
$balance = tools::readCache('bids_balance_' . $user_id);
if (empty($balance)) {
$balance = database::getInstance()->getRow("SELECT SUM(credit) - SUM(debit) AS balance FROM " . DB_PREFIX . "bids WHERE user_id = {$user_id}");
tools::writeCache('bids_balance_' . $user_id, $balance);
}
$result['Balance'] = $balance['balance'];
}
$result['Auction']['price'] = $result['Auction']['price'];
$result['Auction']['serverTimestamp'] = time();
$result['Auction']['serverTimeString'] = date('d-m-Y, H:i:s');
$result['Auction']['time_left'] = strtotime($result['Auction']['end_time']) - time();
if ($result['Auction']['time_left'] <= 0 && $result['Auction']['closed'] == 0) {
$result['Auction']['time_left'] = 1;
}
if ($site_online == 'no') {
$result['Auction']['isPeakNow'] = 0;
示例3: get_online_users
function get_online_users()
{
$dir = _DIR_ . '/data/';
$files = scandir($dir);
$count = 0;
foreach ($files as $filename) {
if (is_dir($dir . $filename)) {
continue;
}
if (substr($filename, 0, 11) == 'user_count_') {
$isOnline = tools::readCache($filename);
if (!empty($isOnline)) {
$count++;
} else {
tools::deleteCache($filename);
}
}
}
return $count;
}
示例4: getUserInfos
private function getUserInfos()
{
if (isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) {
$isOnline = tools::readCache('user_count_' . $_SESSION['user_id']);
if (!empty($isOnline)) {
tools::deleteCache('user_count_' . $_SESSION['user_id']);
tools::writeCache('user_count_' . $_SESSION['user_id'], $_SESSION['user_id'], 300);
} else {
tools::writeCache('user_count_' . $_SESSION['user_id'], $_SESSION['user_id'], 300);
}
$balance = $this->db->select("fetch", "bids", "SUM(credit) - SUM(debit) AS total", array("user_id" => $_SESSION['user_id']));
$this->user['balance'] = $balance['total'];
}
}
示例5: get
$data['user_id'] = $row['user_id'];
$data['autobid'] = $row['id'];
$data['bid_debit'] = get('bid_debit', $data['auction_id'], 0);
$data['price_increment'] = get('price_increment', $data['auction_id'], 0);
$data['time_increment'] = get('time_increment', $data['auction_id'], 0);
$result = bid($data);
}
}
}
}
sleep(4);
}
tools::deleteCache('autobid.pid');
break;
case 'close':
if (tools::readCache('close.pid')) {
return false;
} else {
tools::writeCache('close.pid', microtime(), 50);
}
$db = database::getInstance();
$isPeakNow = tools::isPeakNow();
$expireTime = time() + 60;
while (time() < $expireTime) {
$sql = "SELECT id, peak_only, end_time FROM " . DB_PREFIX . "auctions WHERE end_time <= '" . date('Y-m-d H:i:s') . "' AND closed=0 AND active=1 AND status_id=3";
if ($res = $db->getRows($sql)) {
if (sizeof($res) > 0) {
foreach ($res as $auction) {
if (checkCanClose($auction['id'], $isPeakNow) == false) {
if ($auction['peak_only'] == 1 && !$isPeakNow) {
$peak = tools::isPeakNow(true);