mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
0.12.4
This commit is contained in:
parent
a34932b704
commit
25590c0db2
@ -29,6 +29,7 @@ type DocIndexStorage struct {
|
||||
|
||||
var idxMu sync.Mutex
|
||||
var mapStorage map[string](*DocIndexStorage)
|
||||
var mapStorageMu sync.Mutex
|
||||
|
||||
func init() {
|
||||
mapStorage = make(map[string](*DocIndexStorage))
|
||||
@ -55,6 +56,8 @@ func NewDocIndexStorage(storeName string) *DocIndexStorage { // 存储器,文
|
||||
}
|
||||
|
||||
// 缓存无则锁后创建返回并存缓存
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
idxMu.Lock() // 上锁
|
||||
defer idxMu.Unlock() // 解锁
|
||||
cacheStore = getStorage(cacheName) // 再次尝试取用缓存中存储器
|
||||
@ -132,8 +135,10 @@ func (s *DocIndexStorage) Close() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock() // 对象锁
|
||||
defer s.mu.Unlock() // 对象解锁
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
s.mu.Lock() // 对象锁
|
||||
defer s.mu.Unlock() // 对象解锁
|
||||
if s.closing {
|
||||
return
|
||||
}
|
||||
@ -159,7 +164,10 @@ func (s *DocIndexStorage) IsClose() bool {
|
||||
|
||||
func onExit() {
|
||||
for k := range mapStorage {
|
||||
mapStorage[k].Close()
|
||||
s := mapStorage[k]
|
||||
if s != nil {
|
||||
s.Close()
|
||||
}
|
||||
}
|
||||
cmn.Info("退出DocIndexStorage")
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ var zeroUint16Bytes []byte = cmn.Uint16ToBytes(0) // 索引件数的key
|
||||
|
||||
var idxMu sync.Mutex
|
||||
var mapStorage map[string](*WordIndexStorage)
|
||||
var mapStorageMu sync.Mutex
|
||||
|
||||
func init() {
|
||||
mapStorage = make(map[string](*WordIndexStorage))
|
||||
@ -60,6 +61,8 @@ func NewWordIndexStorage(storeName string) *WordIndexStorage { // 存储器,
|
||||
}
|
||||
|
||||
// 缓存无则锁后创建返回并存缓存
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
idxMu.Lock() // 上锁
|
||||
defer idxMu.Unlock() // 解锁
|
||||
cacheStore = getStorage(cacheName) // 再次尝试取用缓存中存储器
|
||||
@ -191,8 +194,10 @@ func (s *WordIndexStorage) Close() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock() // 对象锁
|
||||
defer s.mu.Unlock() // 对象解锁
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
s.mu.Lock() // 对象锁
|
||||
defer s.mu.Unlock() // 对象解锁
|
||||
if s.closing {
|
||||
return
|
||||
}
|
||||
@ -218,7 +223,10 @@ func (s *WordIndexStorage) IsClose() bool {
|
||||
|
||||
func onExit() {
|
||||
for k := range mapStorage {
|
||||
mapStorage[k].Close()
|
||||
s := mapStorage[k]
|
||||
if s != nil {
|
||||
s.Close()
|
||||
}
|
||||
}
|
||||
cmn.Info("退出WordIndexStorage")
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ type LogDataStorage struct {
|
||||
var zeroUint32Bytes []byte = cmn.Uint32ToBytes(0)
|
||||
var ldbMu sync.Mutex
|
||||
var mapStorage map[string](*LogDataStorage)
|
||||
var mapStorageMu sync.Mutex
|
||||
|
||||
func init() {
|
||||
mapStorage = make(map[string](*LogDataStorage))
|
||||
@ -65,6 +66,8 @@ func NewLogDataStorage(storeName string) *LogDataStorage { // 存储器,文档
|
||||
}
|
||||
|
||||
// 缓存无则锁后创建返回并存缓存
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
ldbMu.Lock() // 上锁
|
||||
defer ldbMu.Unlock() // 解锁
|
||||
cacheStore = getCacheStore(cacheName) // 再次尝试取用缓存中存储器
|
||||
@ -280,8 +283,10 @@ func (s *LogDataStorage) Close() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock() // 锁
|
||||
defer s.mu.Unlock() // 解锁
|
||||
mapStorageMu.Lock() // 缓存map锁
|
||||
defer mapStorageMu.Unlock() // 缓存map解锁
|
||||
s.mu.Lock() // 锁
|
||||
defer s.mu.Unlock() // 解锁
|
||||
if s.closing {
|
||||
return
|
||||
}
|
||||
@ -361,7 +366,10 @@ func (s *LogDataStorage) IsClose() bool {
|
||||
|
||||
func onExit() {
|
||||
for k := range mapStorage {
|
||||
mapStorage[k].Close()
|
||||
s := mapStorage[k]
|
||||
if s != nil {
|
||||
s.Close()
|
||||
}
|
||||
}
|
||||
cmn.Info("退出LogDataStorage")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user