Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
内存锁调整gcache->gmlock
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Aug 30, 2018
1 parent 0745952 commit 71533d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gkvdb/gkvdb_auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"errors"
"gitee.com/johng/gf/g/os/glog"
"gitee.com/johng/gf/g/os/gfile"
"gitee.com/johng/gf/g/os/gcache"
"gitee.com/johng/gf/g/encoding/gbinary"
"gitee.com/johng/gf/g/os/gmlock"
)

// 数据文件自动整理
Expand Down Expand Up @@ -45,10 +45,10 @@ func (db *DB) startAutoSyncingLoop() {
// 数据,将最大的空闲块依次往后挪,直到文件末尾,然后truncate文件
func (table *Table) autoCompactingData() error {
key := "auto_compacting_data_cache_key_for_" + table.db.path + table.name
if !gcache.Lock(key, 10000) {
if !gmlock.TryLock(key, 10000) {
return nil
}
defer gcache.Unlock(key)
defer gmlock.Unlock(key)

table.mu.Lock()
defer table.mu.Unlock()
Expand Down Expand Up @@ -127,10 +127,10 @@ func (table *Table) autoCompactingData() error {
// 元数据,将最大的空闲块依次往后挪,直到文件末尾,然后truncate文件
func (table *Table) autoCompactingMeta() error {
key := "auto_compacting_meta_cache_key_for_" + table.db.path + table.name
if !gcache.Lock(key, 10000) {
if !gmlock.TryLock(key, 10000) {
return nil
}
defer gcache.Unlock(key)
defer gmlock.Unlock(key)

table.mu.Lock()
defer table.mu.Unlock()
Expand Down

0 comments on commit 71533d8

Please sign in to comment.