MCPcopy
hub / github.com/kubernetes/client-go / Add

Method Add

tools/cache/fifo.go:139–153  ·  view source on GitHub ↗

Add inserts an item, and puts it in the queue. The item is only enqueued if it doesn't already exist in the set.

(obj interface{})

Source from the content-addressed store, hash-verified

137// Add inserts an item, and puts it in the queue. The item is only enqueued
138// if it doesn't already exist in the set.
139func (f *FIFO) Add(obj interface{}) error {
140 id, err := f.keyFunc(obj)
141 if err != nil {
142 return KeyError{obj, err}
143 }
144 f.lock.Lock()
145 defer f.lock.Unlock()
146 f.populated = true
147 if _, exists := f.items[id]; !exists {
148 f.queue = append(f.queue, id)
149 }
150 f.items[id] = obj
151 f.cond.Broadcast()
152 return nil
153}
154
155// AddIfNotPresent inserts an item, and puts it in the queue. If the item is already
156// present in the set, it is neither enqueued nor added to the set.

Callers 8

UpdateMethod · 0.95
TestFIFO_basicFunction · 0.95
TestFIFO_requeueOnPopFunction · 0.95
TestFIFO_addUpdateFunction · 0.95
TestFIFO_addReplaceFunction · 0.95
TestFIFO_addIfNotPresentFunction · 0.95
TestFIFO_HasSyncedFunction · 0.95

Calls

no outgoing calls

Tested by 7

TestFIFO_basicFunction · 0.76
TestFIFO_requeueOnPopFunction · 0.76
TestFIFO_addUpdateFunction · 0.76
TestFIFO_addReplaceFunction · 0.76
TestFIFO_addIfNotPresentFunction · 0.76
TestFIFO_HasSyncedFunction · 0.76