aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/cache.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/cache.ts')
-rw-r--r--src/lib/cache.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/cache.ts b/src/lib/cache.ts
new file mode 100644
index 00000000..079c561b
--- /dev/null
+++ b/src/lib/cache.ts
@@ -0,0 +1,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;
+}