Skip to content

Commit

Permalink
write cache to file asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Aug 27, 2024
1 parent 6692efa commit 568b431
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions m3u/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ func Handler(w http.ResponseWriter, r *http.Request, db *database.Instance) {

// If no valid cache, generate content and update cache
content := GenerateAndCacheM3UContent(db, r)
if err := WriteCacheToFile(content); err != nil {
log.Printf("[ERROR] Failed to write cache to file: %v\n", err)
}
go func() {
if err := WriteCacheToFile(content); err != nil {
log.Printf("[ERROR] Failed to write cache to file: %v\n", err)
}
}()

if _, err := w.Write([]byte(content)); err != nil {
log.Printf("[ERROR] Failed to write response: %v\n", err)
Expand Down

0 comments on commit 568b431

Please sign in to comment.