File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ import { prisma } from "@dub/prisma" ;
2+ import "dotenv-flow/config" ;
3+ import { linkCache } from "../lib/api/links/cache" ;
4+
5+ // script to backfill link cache for links with webhooks
6+ async function main ( ) {
7+ const links = await prisma . link . findMany ( {
8+ where : {
9+ webhooks : {
10+ some : { } ,
11+ } ,
12+ } ,
13+ include : {
14+ webhooks : true ,
15+ } ,
16+ } ) ;
17+
18+ console . log ( links . length ) ;
19+ console . log ( JSON . stringify ( links , null , 2 ) ) ;
20+
21+ const res = await linkCache . mset ( links ) ;
22+ console . log ( res ) ;
23+ }
24+
25+ main ( ) ;
Original file line number Diff line number Diff line change 1+ import { prisma } from "@dub/prisma" ;
2+ import "dotenv-flow/config" ;
3+ import { redis } from "../lib/upstash" ;
4+
5+ const batch = 3 ;
6+
7+ // script to remove old redis link cache entries
8+ async function main ( ) {
9+ const domains = await prisma . domain . findMany ( {
10+ orderBy : {
11+ createdAt : "asc" ,
12+ } ,
13+ take : 500 ,
14+ skip : batch * 500 ,
15+ } ) ;
16+
17+ for ( const domain of domains ) {
18+ const res = await redis . del ( domain . slug ) ;
19+ console . log ( `Deleted ${ domain . slug } from redis: ${ res } ` ) ;
20+ }
21+ }
22+
23+ main ( ) ;
You can’t perform that action at this time.
0 commit comments