-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-waf-resource
- Loading branch information
Showing
15 changed files
with
243 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"nextjs-website": minor | ||
--- | ||
|
||
Add autoplay to the swiper in Home page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"gitbook-docs": patch | ||
--- | ||
|
||
Update doc parsing to show images in tables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"infrastructure": patch | ||
--- | ||
|
||
Fixed codebuild cicd lambda permissions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"nextjs-website": patch | ||
--- | ||
|
||
Implement caching for API responses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// In-memory cache store | ||
interface CacheEntry<T> { | ||
readonly data: T; | ||
readonly expiry: number; | ||
} | ||
|
||
const cacheStore = new Map<string, CacheEntry<unknown>>(); | ||
|
||
export const getCacheKey = (prefix: string, ...args: readonly string[]) => | ||
`cache:${prefix}:${args.join(':')}`; | ||
|
||
export const withCache = async <T>( | ||
key: string, | ||
fetchFn: () => Promise<T>, | ||
cache_expiry_in_seconds: number | ||
): Promise<T> => { | ||
const now = Date.now(); | ||
const cached = cacheStore.get(key); | ||
|
||
// Check if we have valid cached data | ||
if (cached && cached.expiry > now) { | ||
return cached.data as T; | ||
} | ||
|
||
// If no cached data or expired, fetch and cache | ||
// eslint-disable-next-line functional/no-try-statements | ||
try { | ||
const data = await fetchFn(); | ||
// eslint-disable-next-line functional/no-expression-statements | ||
cacheStore.set(key, { | ||
data, | ||
expiry: now + cache_expiry_in_seconds * 1000, | ||
}); | ||
return data; | ||
} catch (error) { | ||
// eslint-disable-next-line functional/no-expression-statements | ||
console.error('Cache error:', error); | ||
return fetchFn(); | ||
} | ||
}; |
Oops, something went wrong.