aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/cache.ts
blob: 079c561b0266ccdcb07ec659c9ca8f49c57a80d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// src/lib/server/cache.ts
let cachedData: any = null;

async function fetchData() {
  // Fetch data from your API
  const response = await fetch('https://api.example.com/data');
  cachedData = await response.json();
}

// Initialize cache and set up periodic updates
fetchData(); // Initial fetch
setInterval(fetchData, 60000); // Update every 60 seconds

export function getCachedData() {
  return cachedData;
}