refactor: replace standard log with zap logger and optimize code patterns
- Migrate all log.Printf/log.Println calls to structured zap logging - Use cmp.Or for cleaner default value handling - Replace manual loops with slices.ContainsFunc/IndexFunc - Add batch query methods (IsLikedBatch, IsFavoritedBatch) to solve N+1 problem - Update JSON tags from omitempty to omitzero for numeric fields - Use errgroup-style wg.Go for worker goroutines - Remove duplicate casbin/v2 dependency (keeping v3) - Add plans/ to gitignore
This commit is contained in:
11
internal/cache/cache.go
vendored
11
internal/cache/cache.go
vendored
@@ -1,6 +1,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
@@ -123,17 +124,11 @@ func GetSettings() Settings {
|
||||
}
|
||||
|
||||
func normalizeKey(key string) string {
|
||||
if settings.KeyPrefix == "" {
|
||||
return key
|
||||
}
|
||||
return settings.KeyPrefix + ":" + key
|
||||
return cmp.Or(settings.KeyPrefix, "") + ":" + key
|
||||
}
|
||||
|
||||
func normalizePrefix(prefix string) string {
|
||||
if settings.KeyPrefix == "" {
|
||||
return prefix
|
||||
}
|
||||
return settings.KeyPrefix + ":" + prefix
|
||||
return cmp.Or(settings.KeyPrefix, "") + ":" + prefix
|
||||
}
|
||||
|
||||
func SetWithJitter(c Cache, key string, value interface{}, ttl time.Duration, jitterRatio float64) {
|
||||
|
||||
Reference in New Issue
Block a user