🧵 Replace cache with thread-safe sync.Map

This commit is contained in:
2024-07-29 13:31:48 +08:00
parent c46d7fa312
commit cac19b2c93
3 changed files with 33 additions and 21 deletions

View File

@@ -93,7 +93,7 @@ func AnalyzeAttachment(file models.Attachment) error {
if linked && err != nil {
return fmt.Errorf("unable to link file record: %v", err)
} else if !linked {
metadataCache[file.ID] = file
metadataCache.Store(file.ID, file)
if err := tx.Save(&file).Error; err != nil {
tx.Rollback()
return fmt.Errorf("unable to save file record: %v", err)