From a9b44cbae79e9c01cff07964a45e1c7efa7fb241 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Dec 2024 19:20:36 -0800 Subject: cached rates --- src/lib/cache.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/lib/cache.ts (limited to 'src/lib/cache.ts') 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; +} -- cgit v1.2.3