1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-11-15 22:10:50 -05: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),
}));