Remove cache on empty results query
Cette révision appartient à :
Parent
088612bed3
révision
6f983260ae
1 fichiers modifiés avec 6 ajouts et 2 suppressions
|
@ -92,7 +92,9 @@ func ByQuery(c *gin.Context, pagenum int, countAll bool, withUser bool, deleted
|
|||
return torrentParam, torrentCache.Torrents, torrentCache.Count, nil
|
||||
}
|
||||
totalHits, tor, err := torrentParam.Find(models.ElasticSearchClient)
|
||||
cache.C.Set(torrentParam.Identifier(), &structs.TorrentCache{tor, int(totalHits)}, 5*time.Minute)
|
||||
if totalHits > 0 {
|
||||
cache.C.Set(torrentParam.Identifier(), &structs.TorrentCache{tor, int(totalHits)}, 5*time.Minute)
|
||||
}
|
||||
// Convert back to non-json torrents
|
||||
return torrentParam, tor, int(totalHits), err
|
||||
}
|
||||
|
@ -248,7 +250,9 @@ func byQueryPostgres(c *gin.Context, pagenum int, countAll bool, withUser bool,
|
|||
} else {
|
||||
tor, err = torrents.FindOrderByNoCount(¶meters, orderBy, int(search.Max), int(search.Max*(search.Offset-1)))
|
||||
}
|
||||
cache.C.Set(search.Identifier(), &structs.TorrentCache{tor, count}, 5*time.Minute)
|
||||
if len(tor) > 0 {
|
||||
cache.C.Set(search.Identifier(), &structs.TorrentCache{tor, count}, 5*time.Minute)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Référencer dans un nouveau ticket