feat: Add compression and caching to movie routes
Adds gzip compression middleware and an in-memory cache for movie data to improve performance. Also adds database indexes for common query patterns. Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
co-authored by
mathieumoran1
parent
1e7ab962d6
commit
3884ce6492
@@ -20,4 +20,11 @@ const movieSchema = new mongoose.Schema({
|
||||
watchedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }]
|
||||
}, { timestamps: true });
|
||||
|
||||
// Common read patterns:
|
||||
// - list movies for a year, sorted by title
|
||||
// - check "last update" per year (sort by updatedAt)
|
||||
movieSchema.index({ year: 1, title: 1 });
|
||||
movieSchema.index({ year: 1, updatedAt: -1 });
|
||||
movieSchema.index({ year: 1, imdb_id: 1 });
|
||||
|
||||
module.exports = mongoose.model("Movie", movieSchema);
|
||||
|
||||
Reference in New Issue
Block a user