mirror of
https://github.com/nxshock/zkv.git
synced 2024-11-27 11:21:02 +05:00
Replace Mutex with RWMutex
This commit is contained in:
parent
4ec53665af
commit
d40b88eebb
6
zkv.go
6
zkv.go
@ -18,7 +18,7 @@ type Database struct {
|
|||||||
filePath string
|
filePath string
|
||||||
offset int64
|
offset int64
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) Close() error {
|
func (db *Database) Close() error {
|
||||||
@ -60,8 +60,8 @@ func (db *Database) Set(key, value interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) Get(key, value interface{}) error {
|
func (db *Database) Get(key, value interface{}) error {
|
||||||
db.mu.Lock()
|
db.mu.RLock()
|
||||||
defer db.mu.Unlock()
|
defer db.mu.RUnlock()
|
||||||
|
|
||||||
hashToFind, err := hashInterface(key)
|
hashToFind, err := hashInterface(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user