@@ -39,8 +39,10 @@ func TestNearCacheOperationsAgainstMapAndCache(t *testing.T) {
39
39
nameMap coherence.NamedMap [int , Person ]
40
40
test func (t * testing.T , namedCache coherence.NamedMap [int , Person ])
41
41
}{
42
- {"TestNearCacheBasicNamedMap" , GetNearCacheNamedMap [int , Person ](g , session , "near-cache-basic-map" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearCacheBasic },
43
- {"TestNearCacheBasicNamedCache" , GetNearCacheNamedCache [int , Person ](g , session , "near-cache-basic-cache" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearCacheBasic },
42
+ {"RunTestNearCacheBasicNamedMap" , GetNearCacheNamedMap [int , Person ](g , session , "near-cache-basic-map" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearCacheBasic },
43
+ {"RunTestNearCacheBasicNamedCache" , GetNearCacheNamedCache [int , Person ](g , session , "near-cache-basic-cache" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearCacheBasic },
44
+ {"RunTestNearWithClearNamedCache" , GetNearCacheNamedCache [int , Person ](g , session , "near-cache-clear-cache" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearWithClear },
45
+ {"RunTestNearWithClearNamedMap" , GetNearCacheNamedCache [int , Person ](g , session , "near-cache-clear-map" , coherence .WithNearCache (& nearCacheOptions10Seconds )), RunTestNearWithClear },
44
46
{"RunTestNearCacheRemovesNamedMap" , GetNearCacheNamedMap [int , Person ](g , session , "near-cache-removes-map" , coherence .WithNearCache (& nearCacheOptions120Seconds )), RunTestNearCacheRemoves },
45
47
{"RunTestNearCacheRemovesNamedCache" , GetNearCacheNamedCache [int , Person ](g , session , "near-cache-removes-cache" , coherence .WithNearCache (& nearCacheOptions120Seconds )), RunTestNearCacheRemoves },
46
48
{"RunTestNearCacheContainsKeyNamedMap" , GetNearCacheNamedMap [int , Person ](g , session , "near-cache-removes-map" , coherence .WithNearCache (& nearCacheOptions120Seconds )), RunTestNearCacheContainsKey },
@@ -347,6 +349,51 @@ func RunTestNearCacheWithHighUnits(t *testing.T, namedMap coherence.NamedMap[int
347
349
g .Expect (namedMap .GetNearCacheStats ().GetCachePrunes ()).To (gomega .Equal (int64 (1 )))
348
350
}
349
351
352
+ // RunTestNearWithClear tests a near cache that issues puts, get then clears..
353
+ func RunTestNearWithClear (t * testing.T , namedMap coherence.NamedMap [int , Person ]) {
354
+ var (
355
+ g = gomega .NewWithT (t )
356
+ err error
357
+ p1Get * Person
358
+ p2Get * Person
359
+ )
360
+
361
+ err = namedMap .Clear (ctx )
362
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
363
+
364
+ p1 := Person {ID : 1 , Name : "p1" }
365
+ p2 := Person {ID : 2 , Name : "p2" }
366
+
367
+ for i := 1 ; i < 100 ; i ++ {
368
+ _ , err = namedMap .Put (ctx , p1 .ID , p1 )
369
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
370
+
371
+ _ , err = namedMap .Put (ctx , p2 .ID , p2 )
372
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
373
+
374
+ AssertSize [int , Person ](g , namedMap , 2 )
375
+
376
+ p1Get , err = namedMap .Get (ctx , p1 .ID )
377
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
378
+ g .Expect (* p1Get ).Should (gomega .Equal (p1 ))
379
+
380
+ p2Get , err = namedMap .Get (ctx , p2 .ID )
381
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
382
+ g .Expect (* p2Get ).Should (gomega .Equal (p2 ))
383
+
384
+ err = namedMap .Clear (ctx )
385
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
386
+
387
+ p1Get , err = namedMap .Get (ctx , p1 .ID )
388
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
389
+ g .Expect (p1Get ).Should (gomega .BeNil ())
390
+
391
+ p2Get , err = namedMap .Get (ctx , p2 .ID )
392
+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
393
+ g .Expect (p2Get ).Should (gomega .BeNil ())
394
+ }
395
+ }
396
+
350
397
// RunTestNearCacheWithHighUnits tests near cache with high units of 100 and accessing entries to ensure they are not removed.
351
398
func RunTestNearCacheWithHighUnitsAccess (t * testing.T , namedMap coherence.NamedMap [int , Person ]) {
352
399
var (
0 commit comments