fix(translator): enhance signature cache clearing logic and update test cases with model name

This commit is contained in:
hkfires
2026-01-20 20:02:29 +08:00
parent e49a1c07bf
commit 9b72ea9efa
2 changed files with 9 additions and 1 deletions

View File

@@ -156,7 +156,13 @@ func GetCachedSignature(modelName, sessionID, text string) string {
// ClearSignatureCache clears signature cache for a specific session or all sessions.
func ClearSignatureCache(sessionID string) {
if sessionID != "" {
signatureCache.Delete(sessionID)
signatureCache.Range(func(key, _ any) bool {
kStr, ok := key.(string)
if ok && strings.HasSuffix(kStr, "#"+sessionID) {
signatureCache.Delete(key)
}
return true
})
} else {
signatureCache.Range(func(key, _ any) bool {
signatureCache.Delete(key)