DeleteCachedSignatureRequired removes one exact cached signature.
(ctx context.Context, modelName, text string)
| 250 | |
| 251 | // DeleteCachedSignatureRequired removes one exact cached signature. |
| 252 | func DeleteCachedSignatureRequired(ctx context.Context, modelName, text string) error { |
| 253 | if text == "" { |
| 254 | return nil |
| 255 | } |
| 256 | if client, homeMode, errClient := currentSignatureKVClient(); homeMode { |
| 257 | if errClient != nil { |
| 258 | return errClient |
| 259 | } |
| 260 | _, errDel := client.KVDel(ctx, signatureKVKey(modelName, text)) |
| 261 | return errDel |
| 262 | } |
| 263 | groupKey := GetModelGroup(modelName) |
| 264 | textHash := hashText(text) |
| 265 | val, ok := signatureCache.Load(groupKey) |
| 266 | if !ok { |
| 267 | return nil |
| 268 | } |
| 269 | sc := val.(*groupCache) |
| 270 | sc.mu.Lock() |
| 271 | delete(sc.entries, textHash) |
| 272 | isEmpty := len(sc.entries) == 0 |
| 273 | sc.mu.Unlock() |
| 274 | if isEmpty { |
| 275 | signatureCache.Delete(groupKey) |
| 276 | } |
| 277 | return nil |
| 278 | } |
| 279 | |
| 280 | // HasValidSignature checks if a signature is valid (non-empty and long enough) |
| 281 | func HasValidSignature(modelName, signature string) bool { |