From d7485b186f72742ee0a1bf34e7fc818b53f20870 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期五, 12 十一月 2021 16:02:18 +0800
Subject: [PATCH] fix foreach

---
 store_test.go |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/store_test.go b/store_test.go
index 870c869..bea420d 100644
--- a/store_test.go
+++ b/store_test.go
@@ -1,7 +1,6 @@
 package boltcache
 
 import (
-	"strconv"
 	"testing"
 	"time"
 )
@@ -18,19 +17,27 @@
 
 	//go consume(ls)
 	//
-	for i := 0; i < 100; i++ {
-		ls.ApplyLog([]byte("hello world " + strconv.Itoa(i)))
-		time.Sleep(time.Millisecond * 100)
-	}
+	//for i := 0; i < 10; i++ {
+	//	ls.ApplyLog([]byte("hello world " + strconv.Itoa(i)))
+	//	time.Sleep(time.Millisecond * 100)
+	//}
 
 	ls.printLog("Size = ", ls.Size())
 
-	ls.ForEach(func(v []byte) error {
-		ls.printLog("val=:", string(v))
+	var logs []*LogCon
+	ls.ForEach(func(log *LogCon) error {
+		ls.printLog("val=:", string(log.GetData()))
+
+		logs = append(logs, log)
+		time.Sleep(time.Millisecond * 100)
+
 		return nil
 	})
 
-	consume(ls)
+	for _, log := range logs {
+		ls.Delete(log)
+	}
+	//consume(ls)
 }
 
 func consume(ls *LogStore) {

--
Gitblit v1.8.0