MCPcopy Index your code
hub / github.com/git-bug/git-bug / write

Method write

cache/subcache.go:154–187  ·  view source on GitHub ↗

Write will serialize on disk the entity cache file

()

Source from the content-addressed store, hash-verified

152
153// Write will serialize on disk the entity cache file
154func (sc *SubCache[EntityT, ExcerptT, CacheT]) write() error {
155 sc.mu.RLock()
156 defer sc.mu.RUnlock()
157
158 var data bytes.Buffer
159
160 aux := struct {
161 Version uint
162 Excerpts map[entity.Id]ExcerptT
163 }{
164 Version: sc.version,
165 Excerpts: sc.excerpts,
166 }
167
168 encoder := gob.NewEncoder(&data)
169
170 err := encoder.Encode(aux)
171 if err != nil {
172 return err
173 }
174
175 f, err := sc.repo.LocalStorage().Create(filepath.Join("cache", sc.namespace))
176 if err != nil {
177 return err
178 }
179
180 _, err = f.Write(data.Bytes())
181 if err != nil {
182 _ = f.Close()
183 return err
184 }
185
186 return f.Close()
187}
188
189func (sc *SubCache[EntityT, ExcerptT, CacheT]) Build() <-chan BuildEvent {
190 // value chosen experimentally as giving the fasted indexing, while

Callers 5

BuildMethod · 0.95
RemoveMethod · 0.95
RemoveAllMethod · 0.95
MergeAllMethod · 0.95
entityUpdatedMethod · 0.95

Calls 4

LocalStorageMethod · 0.65
BytesMethod · 0.65
CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected