Add redis caching for 404s

This commit is contained in:
Ajay Ramachandran
2021-02-20 21:13:46 -05:00
parent 597dff7ac3
commit 01d318d902
6 changed files with 73 additions and 13 deletions

View File

@@ -11,6 +11,8 @@ import {getFormattedTime} from '../utils/getFormattedTime';
import {isUserTrustworthy} from '../utils/isUserTrustworthy';
import {dispatchEvent} from '../utils/webhookUtils';
import {Request, Response} from 'express';
import { skipSegmentsKey } from '../middleware/redisKeys';
import redis from '../utils/redis';
function sendWebhookNotification(userID: string, videoID: string, UUID: string, submissionCount: number, youtubeData: any, {submissionStart, submissionEnd}: { submissionStart: number; submissionEnd: number; }, segmentInfo: any) {
@@ -496,6 +498,9 @@ export async function postSkipSegments(req: Request, res: Response) {
//add to private db as well
privateDB.prepare('run', "INSERT INTO sponsorTimes VALUES(?, ?, ?)", [videoID, hashedIP, timeSubmitted]);
// Clear redis cache for this video
redis.delAsync(skipSegmentsKey(videoID));
} catch (err) {
//a DB change probably occurred
res.sendStatus(502);