MCPcopy
hub / github.com/pocketbase/pocketbase / Remove

Method Remove

tools/store/store.go:61–79  ·  view source on GitHub ↗

Remove removes a single entry from the store. Remove does nothing if key doesn't exist in the store.

(key K)

Source from the content-addressed store, hash-verified

59//
60// Remove does nothing if key doesn't exist in the store.
61func (s *Store[K, T]) Remove(key K) {
62 s.mu.Lock()
63 defer s.mu.Unlock()
64
65 delete(s.data, key)
66 s.deleted++
67
68 // reassign to a new map so that the old one can be gc-ed because it doesn't shrink
69 //
70 // @todo remove after https://github.com/golang/go/issues/20135
71 if s.deleted >= ShrinkThreshold {
72 newData := make(map[K]T, len(s.data))
73 for k, v := range s.data {
74 newData[k] = v
75 }
76 s.data = newData
77 s.deleted = 0
78 }
79}
80
81// Has checks if element with the specified key exist or not.
82func (s *Store[K, T]) Has(key K) bool {

Callers 4

TestNewFunction · 0.45
TestRemoveFunction · 0.45
TestShrinkFunction · 0.45
UnregisterMethod · 0.45

Calls

no outgoing calls

Tested by 3

TestNewFunction · 0.36
TestRemoveFunction · 0.36
TestShrinkFunction · 0.36