@@ -21,7 +21,7 @@ func TestNew(t *testing.T) {
21
21
db .Set ("c" , 1 , time .Millisecond )
22
22
23
23
time .Sleep (20 * time .Millisecond )
24
- as .ElementsMatch (db .Keys ("* " ), []string {"b" , "d" , "e" })
24
+ as .ElementsMatch (db .Keys ("" ), []string {"b" , "d" , "e" })
25
25
})
26
26
27
27
t .Run ("" , func (t * testing.T ) {
@@ -34,7 +34,7 @@ func TestNew(t *testing.T) {
34
34
db .Set ("a" , 1 , 40 * time .Millisecond )
35
35
36
36
time .Sleep (30 * time .Millisecond )
37
- as .ElementsMatch (db .Keys ("* " ), []string {"a" , "c" , "d" , "e" })
37
+ as .ElementsMatch (db .Keys ("" ), []string {"a" , "c" , "d" , "e" })
38
38
})
39
39
40
40
t .Run ("" , func (t * testing.T ) {
@@ -46,14 +46,15 @@ func TestNew(t *testing.T) {
46
46
db .Set ("d" , 1 , 40 * time .Millisecond )
47
47
48
48
time .Sleep (50 * time .Millisecond )
49
- as .Equal (0 , db .Len ( true ))
49
+ as .Equal (0 , len ( db .Keys ( "" ) ))
50
50
})
51
51
}
52
52
53
53
func TestMemoryCache_Set (t * testing.T ) {
54
54
var list []string
55
55
var count = 10000
56
56
var mc = New (WithInterval (100 * time .Millisecond ))
57
+ mc .Clear ()
57
58
for i := 0 ; i < count ; i ++ {
58
59
key := string (utils .AlphabetNumeric .Generate (8 ))
59
60
exp := rand .Intn (1000 )
@@ -69,7 +70,7 @@ func TestMemoryCache_Set(t *testing.T) {
69
70
mc .Set (key , 1 , time .Duration (exp )* time .Millisecond )
70
71
}
71
72
time .Sleep (1100 * time .Millisecond )
72
- assert .ElementsMatch (t , utils .Uniq (list ), mc .Keys ("* " ))
73
+ assert .ElementsMatch (t , utils .Uniq (list ), mc .Keys ("" ))
73
74
}
74
75
75
76
func TestMemoryCache_Get (t * testing.T ) {
@@ -115,7 +116,7 @@ func TestMemoryCache_GetAndRefresh(t *testing.T) {
115
116
list = append (list , key )
116
117
mc .Set (key , 1 , time .Duration (exp )* time .Millisecond )
117
118
}
118
- var keys = mc .Keys ("* " )
119
+ var keys = mc .Keys ("" )
119
120
for _ , key := range keys {
120
121
mc .GetAndRefresh (key , 2 * time .Second )
121
122
}
@@ -141,7 +142,7 @@ func TestMemoryCache_Delete(t *testing.T) {
141
142
mc .Set (key , 1 , time .Duration (exp )* time .Millisecond )
142
143
}
143
144
144
- var keys = mc .Keys ("* " )
145
+ var keys = mc .Keys ("" )
145
146
for i := 0 ; i < 100 ; i ++ {
146
147
deleted := mc .Delete (keys [i ])
147
148
assert .True (t , deleted )
@@ -150,7 +151,7 @@ func TestMemoryCache_Delete(t *testing.T) {
150
151
deleted = mc .Delete (key )
151
152
assert .False (t , deleted )
152
153
}
153
- assert .Equal (t , mc .Len (true ), count - 100 )
154
+ assert .Equal (t , mc .Len (), count - 100 )
154
155
}
155
156
156
157
func TestMaxCap (t * testing.T ) {
@@ -164,5 +165,5 @@ func TestMaxCap(t *testing.T) {
164
165
mc .Set (key , 1 , - 1 )
165
166
}
166
167
time .Sleep (200 * time .Millisecond )
167
- assert .Equal (t , mc .Len (false ), 100 )
168
+ assert .Equal (t , mc .Len (), 100 )
168
169
}
0 commit comments