MCPcopy Create free account
hub / github.com/tbphp/gpt-load / AddKeys

Method AddKeys

internal/keypool/provider.go:301–316  ·  view source on GitHub ↗

AddKeys 批量添加新的 Key 到池和数据库中。

(groupID uint, keys []models.APIKey)

Source from the content-addressed store, hash-verified

299
300// AddKeys 批量添加新的 Key 到池和数据库中。
301func (p *KeyProvider) AddKeys(groupID uint, keys []models.APIKey) error {
302 if len(keys) == 0 {
303 return nil
304 }
305
306 err := p.db.Transaction(func(tx *gorm.DB) error {
307 if err := tx.Create(&keys).Error; err != nil {
308 return err
309 }
310
311 // 使用批量方法添加到缓存
312 return p.addKeysToCacheBatch(groupID, keys)
313 })
314
315 return err
316}
317
318// RemoveKeys 批量从池和数据库中移除 Key。
319func (p *KeyProvider) RemoveKeys(groupID uint, keyValues []string) (int64, error) {

Callers 1

processAndCreateKeysMethod · 0.80

Calls 1

addKeysToCacheBatchMethod · 0.95

Tested by

no test coverage detected