MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / AddItem

Method AddItem

internal/iplibrary/ip_list_sqlite.go:196–217  ·  view source on GitHub ↗
(item *pb.IPItem)

Source from the content-addressed store, hash-verified

194}
195
196func (this *SQLiteIPList) AddItem(item *pb.IPItem) error {
197 if this.isClosed {
198 return nil
199 }
200
201 _, err := this.deleteItemStmt.Exec(item.Id)
202 if err != nil {
203 return err
204 }
205
206 // 如果是删除,则不再创建新记录
207 if item.IsDeleted {
208 return this.UpdateMaxVersion(item.Version)
209 }
210
211 _, err = this.insertItemStmt.Exec(item.ListId, item.ListType, item.IsGlobal, item.Type, item.Id, item.IpFrom, item.IpTo, item.ExpiredAt, item.EventLevel, item.IsDeleted, item.Version, item.NodeId, item.ServerId)
212 if err != nil {
213 return err
214 }
215
216 return this.UpdateMaxVersion(item.Version)
217}
218
219func (this *SQLiteIPList) ReadItems(offset int64, size int64) (items []*pb.IPItem, goNext bool, err error) {
220 if this.isClosed {

Callers 1

TestSQLiteIPList_AddItemFunction · 0.95

Calls 2

UpdateMaxVersionMethod · 0.95
ExecMethod · 0.45

Tested by 1

TestSQLiteIPList_AddItemFunction · 0.76