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

Method Open

internal/utils/kvstore/store.go:150–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148}
149
150func (this *Store) Open() error {
151 err := this.locker.Lock()
152 if err != nil {
153 return err
154 }
155
156 var opt = &pebble.Options{
157 Logger: NewLogger(),
158 }
159
160 if fsutils.DiskIsFast() {
161 opt.BytesPerSync = 1 << 20
162 }
163
164 var memoryMB = memutils.SystemMemoryGB() * 2
165 if memoryMB > 256 {
166 memoryMB = 256
167 }
168 if memoryMB > 4 {
169 opt.MemTableSize = uint64(memoryMB) << 20
170 }
171
172 rawDB, err := pebble.Open(this.path, opt)
173 if err != nil {
174 return err
175 }
176 this.rawDB = rawDB
177
178 // events
179 events.OnClose(func() {
180 _ = this.Close()
181 })
182
183 return nil
184}
185
186func (this *Store) Set(keyBytes []byte, valueBytes []byte) error {
187 return this.rawDB.Set(keyBytes, valueBytes, DefaultWriteOptions)

Callers 9

OpenStoreFunction · 0.95
DefaultStoreFunction · 0.95
RunMethod · 0.45
OpenFileReaderMethod · 0.45
OpenStoreDirFunction · 0.45
openFunction · 0.45
OpenFunction · 0.45
doShutdownMethod · 0.45
doPageLookupMethod · 0.45

Calls 4

CloseMethod · 0.95
OnCloseFunction · 0.92
NewLoggerFunction · 0.85
LockMethod · 0.45

Tested by

no test coverage detected