Proje: Okul B2B App · Hub: Okul B2B App — Conventions

CompaniesService Cache Stratejisi

services/CompaniesService.ts — Firma verisi cache.

Cache

static cache: { data: Company | null; timestamp: number } | null = null;
static CACHE_DURATION = 10 * 60 * 1000; // 10 dakika
 
// Cache key'i x-cid'e göre validate edilir
if (cache.data.id.toString() === customerId) return cache.data;

Cache firma değiştirildiğinde otomatik geçersizleşir (x-cid değişimi).

clearCache()

CompaniesService.clearCache();
// Logout sırasında çağrılır (AuthService.clearAuthRelatedData)

getCompanyById()

getUserCompanies() içinden ID ile arar. Tüm firmaları çekip filtreler.