mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-02 12:06:35 +08:00
使用KV存储实现指标统计
This commit is contained in:
@@ -162,14 +162,22 @@ func (this *Store) Delete(keyBytes []byte) error {
|
||||
}
|
||||
|
||||
func (this *Store) NewDB(dbName string) (*DB, error) {
|
||||
this.mu.Lock()
|
||||
defer this.mu.Unlock()
|
||||
|
||||
// check existence
|
||||
for _, db := range this.dbs {
|
||||
if db.name == dbName {
|
||||
return db, nil
|
||||
}
|
||||
}
|
||||
|
||||
// create new
|
||||
db, err := NewDB(this, dbName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
this.mu.Lock()
|
||||
defer this.mu.Unlock()
|
||||
|
||||
this.dbs = append(this.dbs, db)
|
||||
return db, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user