This commit is contained in:
man00k
2026-01-30 16:49:29 +08:00
parent 83c1e36469
commit 959901fcad
15 changed files with 190 additions and 24 deletions

8
cache/cache.go vendored
View File

@@ -1,14 +1,14 @@
package cache
import (
"code.infininov.com/Infini/unitech-golib/tlog"
"errors"
"github.com/MAN00K/unitech_golib/tlog"
"github.com/creachadair/cityhash"
"sync"
"time"
)
//API
// API
var Nil error = errors.New("cache: nil")
func Set(key string, value interface{}) error {
@@ -27,7 +27,7 @@ func Del(key string) error {
return del(key)
}
//internal
// internal
var dbs map[byte]*db
type db struct {
@@ -59,7 +59,7 @@ func newdb(t time.Duration) *db {
return ret
}
//定期扫描过期的key
// 定期扫描过期的key
func (this *db) flush() {
for range time.NewTicker(this.t).C {
this.doflush()