Verified Commit 9f075cae authored by AtjonTV's avatar AtjonTV
Browse files

Implement Delete

parent 63151dd8
......@@ -48,13 +48,21 @@ func main() {
// Get expected KeyCount (can be wrong after Merge()!!)
count := db.Stats.KeyCount
// Delete value
err8 := db.Delte([]byte("Key"))
// Close database
err8 := db.Close()
err9 := db.Close()
}
```
# Changes
## [2.1.0] (7th Jan 2020)
### Added
* `Database.Delete` to delete a key from the database
## [2.0.1] (11th Dec 2019)
### Changed
......
......@@ -183,6 +183,28 @@ func (db Database) Get(key []byte) ([]byte, error) {
return data, err
}
func (db Database) Delete(key []byte) error {
var err error
if db.ActiveDB == USE_BITCASK {
db.Locks.BitcaskLock.Lock()
err = db.bitcask.Delete(key)
db.Locks.BitcaskLock.Unlock()
}
if db.ActiveDB == USE_LEVELDB {
db.Locks.LeveldbLock.Lock()
err = db.leveldb.Delete(key, nil)
db.Locks.LeveldbLock.Unlock()
}
return err
}
func (db Database) Merge() error {
if db.ActiveDB == USE_BITCASK {
log.Println("Database::Cleanup::BitCask")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment