Improve video data caching and synchronization logic

Modify BunnyStorage to update local cache directly instead of invalidating it, improving performance by avoiding external synchronization calls after successful database updates.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/d05DGZF
This commit is contained in:
sebastjanartic 2025-09-02 15:06:58 +00:00
parent fef1b66bd7
commit af87e190e0

View File

@ -860,15 +860,17 @@ class BunnyStorage implements IStorage {
console.warn(`Database update failed for video ${id}, using cache:`, dbError);
}
// If database update was successful, invalidate cache to refresh with updated data
// If database update was successful, just update local cache - don't sync from Bunny.net
if (dbUpdateSuccessful) {
try {
const { videoSyncService } = await import('./videoSync');
console.log(`Invalidating cache for updated video ${id}...`);
await videoSyncService.initialize();
console.log(`Cache invalidated after updating video ${id}`);
} catch (syncError) {
console.warn('Failed to invalidate cache after video update:', syncError);
const existing = this.videos.get(id);
if (existing) {
const updatedVideo = { ...existing, ...updates, updatedAt: new Date() };
this.videos.set(id, updatedVideo);
console.log(`Updated video ${id} in local cache`);
}
} catch (cacheError) {
console.warn('Failed to update local cache after video update:', cacheError);
}
}