-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Pull Request type Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Issue Number: N/A ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Other information PR-URL: #622 Co-authored-by: Joe Karow <[email protected]> Co-authored-by: InReach [Automated User] <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
- Loading branch information
Showing
101 changed files
with
6,538 additions
and
347 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
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,30 @@ | ||
import { kv as redis } from '@vercel/kv' | ||
import { Logger } from 'tslog' | ||
|
||
const log = new Logger({ name: 'Cache - Slug redirect' }) | ||
|
||
export const readSlugRedirectCache = async (slug: string) => { | ||
try { | ||
if ((await redis.ping()) !== 'PONG') { | ||
log.warn('Skipping cache read - Redis client not connected') | ||
return null | ||
} | ||
const redirectedSlug = await redis.hget<string>('slugRedirect', slug) | ||
return redirectedSlug | ||
} catch (err) { | ||
log.error(err) | ||
return null | ||
} | ||
} | ||
|
||
export const writeSlugRedirectCache = async (slug: string, redirectTo: string) => { | ||
try { | ||
if ((await redis.ping()) !== 'PONG') { | ||
log.warn('Skipping cache write - Redis client not connected') | ||
return | ||
} | ||
await redis.hset('slugRedirect', { [slug]: redirectTo }) | ||
} catch (err) { | ||
log.error(err) | ||
} | ||
} |
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
Oops, something went wrong.