mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-02-06 20:45:37 +08:00
v1.4.1
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package ttlcache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"time"
|
||||
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
)
|
||||
|
||||
var DefaultCache = NewCache()
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package ttlcache
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
)
|
||||
|
||||
func TestNewCache(t *testing.T) {
|
||||
@@ -68,7 +69,7 @@ func TestCache_Read(t *testing.T) {
|
||||
|
||||
total := 0
|
||||
for _, piece := range cache.pieces {
|
||||
//t.Log(len(piece.m), "keys")
|
||||
// t.Log(len(piece.m), "keys")
|
||||
total += len(piece.m)
|
||||
}
|
||||
t.Log(total, "total keys")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ttlcache
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type Piece struct {
|
||||
@@ -16,7 +17,7 @@ func NewPiece(maxItems int) *Piece {
|
||||
return &Piece{m: map[uint64]*Item{}, maxItems: maxItems}
|
||||
}
|
||||
|
||||
func (this *Piece) Add(key uint64, item *Item) () {
|
||||
func (this *Piece) Add(key uint64, item *Item) {
|
||||
this.locker.Lock()
|
||||
if len(this.m) >= this.maxItems {
|
||||
this.locker.Unlock()
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ttlcache
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
)
|
||||
|
||||
func TestPiece_Add(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user