| 139 | } |
| 140 | |
| 141 | func (this *KVIPList) AddItem(item *pb.IPItem) error { |
| 142 | if this.isClosed { |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // 先删除 |
| 147 | var key = this.encoder.EncodeKey(item) |
| 148 | err := this.ipTable.Delete(key) |
| 149 | if err != nil { |
| 150 | return err |
| 151 | } |
| 152 | |
| 153 | // 如果是删除,则不再创建新记录 |
| 154 | if item.IsDeleted { |
| 155 | return this.UpdateMaxVersion(item.Version) |
| 156 | } |
| 157 | |
| 158 | err = this.ipTable.Set(key, item) |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | return this.UpdateMaxVersion(item.Version) |
| 164 | } |
| 165 | |
| 166 | func (this *KVIPList) ReadItems(offset int64, size int64) (items []*pb.IPItem, goNextLoop bool, err error) { |
| 167 | if this.isClosed { |