[*] добавлено кэширование

This commit is contained in:
rsgrinko committed 2021-12-23 23:39:17 +03:00
1 parent aa7b781a03
commit d09a30574d
2 files changed
+21 -3

No files matched your search

+9 -1
View File
@@ -57,10 +57,18 @@
foreach($arrDevices as $device):
$arrUserFields = CUser::getFields($device['user']);
$cacheId = md5('CIoT::isOnline_'.$device['id']);
if(CCache::check($cacheId) and CCache::getAge($cacheId) < DEVICE_ONLINE_TIME) {
$isDeviceOnline = CCache::get($cacheId);
} else {
$isDeviceOnline = CIoT::isOnline($device['id']);
CCache::write($cacheId, $isDeviceOnline);
}
?>
<tr>
<td class="text-center"><a href="boardinfo.php?id=<?php echo $device['id']; ?>"><?php echo $device['id']; ?></a></td>
<td><?php if(CIoT::isOnline($device['id'])) { ?><span class="bg-green label">Online</span><?php } else {?><span class="bg-red label">Offline</span><?php } ?></td>
<td><?php if($isDeviceOnline) { ?><span class="bg-green label">Online</span><?php } else {?><span class="bg-red label">Offline</span><?php } ?></td>
<td><a href="boardinfo.php?id=<?php echo $device['id']; ?>"><?php echo $device['mac']; ?></a></td>
<td><a href="boardinfo.php?id=<?php echo $device['id']; ?>"><?php echo $device['chipid']; ?></a></td>
<td><?php echo $device['hw']; ?></td>
+12 -2
View File
@@ -37,11 +37,21 @@ require_once __DIR__ . '/inc/header.php';
CPagination::execute($_REQUEST['page'], CUser::countUsers(), PAGINATION_LIMIT);
$limit = CPagination::getLimit();
?>
<?php foreach (CUser::getUsers($limit, 'ASC') as $user): ?>
<?php
foreach (CUser::getUsers($limit, 'ASC') as $user):
$cacheId = md5('CUser::isOnline_'.$user['id']);
if(CCache::check($cacheId) and CCache::getAge($cacheId) < 60) {
$isUserOnline = CCache::get($cacheId);
} else {
$isUserOnline = CUser::isOnline($user['id']);
CCache::write($cacheId, $isUserOnline);
}
?>
<tr>
<td class="text-center"><?php echo $user['id']; ?></td>
<td><?php echo $user['login']; ?></td>
<th><?php if (CUser::isOnline($user['id'])) { ?><span
<th><?php if ($isUserOnline) { ?><span
class="bg-green label">Online</span><?php } else { ?><span
class="bg-red label">Offline</span><?php } ?></th>
<td><?php echo $user['name']; ?></td>