1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-15 12:45:33 -04:00

add prefix to redis keys

This commit is contained in:
2025-04-04 08:49:42 -04:00
parent 774c3a5d96
commit 2b9c421d42
9 changed files with 65 additions and 87 deletions

View File

@@ -17,6 +17,7 @@ export const GET = async (): Promise<
> => {
// get all keys (aka slugs)
const slugs = await redis.scan(0, {
match: "hits:*",
type: "string",
// set an arbitrary yet generous upper limit, just in case...
count: 99,
@@ -27,7 +28,7 @@ export const GET = async (): Promise<
// pair the slugs with their hit values
const pages = slugs[1].map((slug, index) => ({
slug,
slug: slug.split(":").pop() as string, // remove the "hits:" prefix
hits: parseInt(values[index], 10),
}));

View File

@@ -96,7 +96,7 @@ const ContactForm = () => {
Markdown syntax
</Link>{" "}
is allowed here, e.g.: <strong>**bold**</strong>, <em>_italics_</em>, [
<Link href="https://jarv.is" plain openInNewTab>
<Link href="https://jarv.is" plain>
links
</Link>
](https://jarv.is), and <code style={{ fontFamily: "var(--fonts-mono)" }}>`code`</code>.

View File

@@ -54,7 +54,7 @@ const Page = () => {
G4techTV Canada
</Link>{" "}
&amp;{" "}
<Link href="https://leolaporte.com/" style={{ fontWeight: 700 }}>
<Link href="https://leo.fm/" style={{ fontWeight: 700 }}>
Leo Laporte
</Link>
. &copy; 2007 G4 Media, Inc.

View File

@@ -12,7 +12,7 @@ const HitCounter = async ({ slug }: { slug: string }) => {
// TODO: maybe don't allow this? or maybe it's fine? kinda unclear how secure this is:
// https://nextjs.org/blog/security-nextjs-server-components-actions
// https://nextjs.org/docs/app/building-your-application/rendering/server-components
const hits = await redis.incr(slug);
const hits = await redis.incr(`hits:${slug}`);
// we have data!
return (