Skip to content

Commit

Permalink
fixed #56 2022-08-01
Browse files Browse the repository at this point in the history
  • Loading branch information
hktalent committed Aug 1, 2022
1 parent 3ab30a0 commit 0c07415
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/util/kvDb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"encoding/json"
"github.com/dgraph-io/badger"
"log"
"sync"
)

var Cache1 *KvDbOp
var DoOnce sync.Once

// https://colobu.com/2017/10/11/badger-a-performant-k-v-store/
// https://juejin.cn/post/6844903814571491335
Expand All @@ -17,15 +15,16 @@ type KvDbOp struct {
}

func NewKvDbOp() *KvDbOp {
DoOnce.Do(func() {
Cache1 = &KvDbOp{}
CacheName11 := ".DbCache"
s1 := GetVal(CacheName)
if "" != s1 {
CacheName11 = s1
}
Cache1.Init(CacheName11)
})
if nil != Cache1 {
return Cache1
}
Cache1 = &KvDbOp{}
CacheName11 := ".DbCache"
s1 := GetVal(CacheName)
if "" != s1 {
CacheName11 = s1
}
Cache1.Init(CacheName11)
return Cache1
}
func (r *KvDbOp) SetExpiresAt(ExpiresAt uint64) {
Expand Down

0 comments on commit 0c07415

Please sign in to comment.