diff options
| author | Adam Soltys <[email protected]> | 2024-12-05 19:20:36 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-12-05 19:20:36 -0800 |
| commit | 53aecbf35d056fc4d70ef1ab12d3634b265f2c0b (patch) | |
| tree | 5caa996fc2eca705fb793e79d63bfbf5f9f93e48 /src/lib/cache.ts | |
| parent | 9c7ade85841e4e608fd9d8468d19b42b79cd9868 (diff) | |
| download | coinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.tar.gz coinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.zip | |
cached rates
Diffstat (limited to 'src/lib/cache.ts')
| -rw-r--r-- | src/lib/cache.ts | 17 |
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; +} |
