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); 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) { if (dbUpdateSuccessful) {
try { try {
const { videoSyncService } = await import('./videoSync'); const existing = this.videos.get(id);
console.log(`Invalidating cache for updated video ${id}...`); if (existing) {
await videoSyncService.initialize(); const updatedVideo = { ...existing, ...updates, updatedAt: new Date() };
console.log(`Cache invalidated after updating video ${id}`); this.videos.set(id, updatedVideo);
} catch (syncError) { console.log(`Updated video ${id} in local cache`);
console.warn('Failed to invalidate cache after video update:', syncError); }
} catch (cacheError) {
console.warn('Failed to update local cache after video update:', cacheError);
} }
} }