1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-05-26 12:32:25 +00:00

11x speed up of subscription page generation

My 30 subscriptions now take 25 ms to generate, instead of around 280.

Around 120 ms were saved by creating a database index.
Around 120 ms were saved by pre-compiling the pug template for video
description timestamps.
The other changes in this commit produced slight improvements.
This commit is contained in:
Cadence Ember 2021-08-26 23:47:53 +12:00
parent 0aa0505009
commit 55065e2a9e
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
4 changed files with 15 additions and 9 deletions

View file

@ -14,7 +14,10 @@ function getToken(req, responseHeaders) {
return null
}
}
db.prepare("REPLACE INTO SeenTokens (token, seen) VALUES (?, ?)").run([token, Date.now()])
db.prepare(
"INSERT INTO SeenTokens (token, seen) VALUES (?, ?)"
+ " ON CONFLICT (token) DO UPDATE SET seen = excluded.seen"
).run([token, Date.now()])
return token
}