You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
570 B

package db
import (
"fmt"
)
type MemDB struct {
db map[string][]byte
}
func NewMemDB() *MemDB {
database := &MemDB{db: make(map[string][]byte)}
return database
}
func (db *MemDB) Set(key []byte, value []byte) {
db.db[string(key)] = value
}
func (db *MemDB) Get(key []byte) []byte {
return db.db[string(key)]
}
func (db *MemDB) GetRange(key []byte, start, end int) []byte {
}
func (db *MemDB) Delete(key []byte) {
delete(db.db, string(key))
}
func (db *MemDB) Print() {
for key, value := range db.db {
fmt.Printf("[%x]:\t[%x]", []byte(key), value)
}
}