feat(cache): implement centralized caching layer for improved performance and reduced API calls
feat(microsoft-integration): enhance inbox and events fetching with caching support feat(auth): include theme and notification settings in user data retrieval feat(profile): improve password visibility toggle functionality feat(planner): optimize event synchronization with Outlook using caching fix(notifications): update mail badge handling for mobile and desktop
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
require_once __DIR__ . '/../http.php';
|
||||
require_once __DIR__ . '/../../config/database.php';
|
||||
require_once __DIR__ . '/../cache.php';
|
||||
|
||||
/**
|
||||
* Normaliseert het Jira domein naar een schone URL zonder slash aan het einde
|
||||
@@ -823,15 +824,18 @@ function jira_get_dashboard_data(int $userId, bool $forceRefresh = false): array
|
||||
];
|
||||
}
|
||||
|
||||
// Sessiecache voor 60 seconden
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
@session_start();
|
||||
}
|
||||
// Cache controle (60 seconden)
|
||||
$cacheKey = "jira_dashboard_user_{$userId}";
|
||||
$cached = $_SESSION[$cacheKey] ?? null;
|
||||
|
||||
if (!$forceRefresh && $cached && is_array($cached) && ($cached['timestamp'] ?? 0) > (time() - 60)) {
|
||||
return array_merge($cached['data'], ['from_cache' => true]);
|
||||
if (!$forceRefresh) {
|
||||
$cachedData = fociz_cache_get($cacheKey);
|
||||
if ($cachedData !== null && is_array($cachedData)) {
|
||||
return array_merge($cachedData, ['from_cache' => true]);
|
||||
}
|
||||
if (session_status() === PHP_SESSION_ACTIVE && !empty($_SESSION[$cacheKey]['data'])) {
|
||||
if (($_SESSION[$cacheKey]['timestamp'] ?? 0) > (time() - 60)) {
|
||||
return array_merge($_SESSION[$cacheKey]['data'], ['from_cache' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ophalen van toegewezen taken
|
||||
@@ -865,10 +869,14 @@ function jira_get_dashboard_data(int $userId, bool $forceRefresh = false): array
|
||||
'default_queue_filter' => $userQueuePref,
|
||||
];
|
||||
|
||||
$_SESSION[$cacheKey] = [
|
||||
'timestamp' => time(),
|
||||
'data' => $data,
|
||||
];
|
||||
fociz_cache_set($cacheKey, $data, 60);
|
||||
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
$_SESSION[$cacheKey] = [
|
||||
'timestamp' => time(),
|
||||
'data' => $data,
|
||||
];
|
||||
}
|
||||
|
||||
// Werk last_sync_at bij in database
|
||||
$stmtUpdate = $db->prepare("UPDATE integrations SET last_sync_at = NOW() WHERE id = ?");
|
||||
@@ -902,6 +910,7 @@ function jira_disconnect(int $userId): bool {
|
||||
}
|
||||
unset($_SESSION["jira_issues_user_{$userId}"]);
|
||||
unset($_SESSION["jira_dashboard_user_{$userId}"]);
|
||||
fociz_cache_delete("jira_dashboard_user_{$userId}");
|
||||
return $stmt->execute([$userId]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user