transx/cache/queue_test.go

25 lines
391 B
Go

package cache
import(
"testing"
"fmt"
)
func GetAndPut(name string,get *BlockingQueueCache,put *BlockingQueueCache){
for{
r,_:=get.Get()
fmt.Printf("%s Get\n",name)
put.Put(r,1)
fmt.Printf("%s Put\n",name)
}
}
func TestAsynchronousCache(t *testing.T){
a:=NewBlockingQueueCache(1)
b:=NewBlockingQueueCache(1)
a.Put(make([]byte,1),1)
go GetAndPut("A",a,b)
GetAndPut("B",b,a)
}