Proje: Okul B2B App · Hub: Okul B2B App — Domain
NotificationService Cache Stratejisi
services/NotificationService.ts — In-memory bildirim cache sistemi.
Cache Davranışı
static allNotifications: Notification[] = [];
static lastFetchTime: number = 0;
static CACHE_DURATION = 60000; // 1 dakika
const needsFreshData = page === 1 ||
(now - lastFetchTime > CACHE_DURATION) ||
allNotifications.length === 0;1 dakikadan eski data → fresh fetch. 1 dakika içinde → cache’den.
getUnreadCount()
getNotifications(1, 1, { read: false }).totalCount — Sadece 1 sonuç çekip toplam sayıyı alır.
clearCache()
NotificationService.clearCache();
// allNotifications = []
// lastFetchTime = 0
// Sonraki fetch API'den gelirBildirim okundu işaretlendiğinde veya yeni bildirim alındığında çağrılır.
markAsRead
await NotificationService.markAsRead(notificationId); // Tekil
await NotificationService.markAsRead([id1, id2, id3]); // ÇokluRelated
- bildirim-sistemi — NotificationContext
- bildirim-api-yapisi — API yapısı