MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / Get

Method Get

driver/hybriddb/db.go:190–216  ·  view source on GitHub ↗
(key []byte)

Source from the content-addressed store, hash-verified

188}
189
190func (db *DB) Get(key []byte) ([]byte, error) {
191 db.mu.RLock()
192 defer db.mu.RUnlock()
193
194 if db.closed {
195 return nil, fmt.Errorf("database is closed")
196 }
197
198 if len(key) == 0 {
199 db.stats.Errors++
200 return nil, fmt.Errorf("key cannot be empty")
201 }
202
203 db.stats.ReadOps++
204
205 v, err := db.db.Get(key, nil)
206 if err != nil {
207 if err == leveldb.ErrNotFound {
208 return nil, nil
209 }
210 db.stats.Errors++
211 return nil, err
212 }
213
214 db.stats.BytesRead += int64(len(v))
215 return v, nil
216}
217
218func (db *DB) Delete(key []byte) error {
219 db.mu.Lock()

Callers 14

TestWriteBatch_RollbackFunction · 0.45
TestWriteBatch_CloseFunction · 0.45
TestDB_PutGetFunction · 0.45
TestDB_DeleteFunction · 0.45
TestDB_SyncOperationsFunction · 0.45
TestDB_WriteBatchFunction · 0.45
TestDB_SnapshotFunction · 0.45
TestDB_ConcurrentAccessFunction · 0.45

Calls

no outgoing calls

Tested by 14

TestWriteBatch_RollbackFunction · 0.36
TestWriteBatch_CloseFunction · 0.36
TestDB_PutGetFunction · 0.36
TestDB_DeleteFunction · 0.36
TestDB_SyncOperationsFunction · 0.36
TestDB_WriteBatchFunction · 0.36
TestDB_SnapshotFunction · 0.36
TestDB_ConcurrentAccessFunction · 0.36