Skip to content

Commit

Permalink
Add max lifetime option to pool
Browse files Browse the repository at this point in the history
  • Loading branch information
garyburd committed Feb 28, 2018
1 parent a69d193 commit a7327d8
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 98 deletions.
28 changes: 14 additions & 14 deletions redis/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import "testing"

func TestPoolList(t *testing.T) {
var idle idleList
var a, b, c idleConn
var a, b, c poolConn

check := func(ics ...*idleConn) {
if idle.count != len(ics) {
t.Fatal("idle.count != len(ics)")
check := func(pcs ...*poolConn) {
if idle.count != len(pcs) {
t.Fatal("idle.count != len(pcs)")
}
if len(ics) == 0 {
if len(pcs) == 0 {
if idle.front != nil {
t.Fatalf("front not nil")
}
Expand All @@ -35,24 +35,24 @@ func TestPoolList(t *testing.T) {
}
return
}
if idle.front != ics[0] {
t.Fatal("front != ics[0]")
if idle.front != pcs[0] {
t.Fatal("front != pcs[0]")
}
if idle.back != ics[len(ics)-1] {
t.Fatal("back != ics[len(ics)-1]")
if idle.back != pcs[len(pcs)-1] {
t.Fatal("back != pcs[len(pcs)-1]")
}
if idle.front.prev != nil {
t.Fatal("front.prev != nil")
}
if idle.back.next != nil {
t.Fatal("back.next != nil")
}
for i := 1; i < len(ics)-1; i++ {
if ics[i-1].next != ics[i] {
t.Fatal("ics[i-1].next != ics[i]")
for i := 1; i < len(pcs)-1; i++ {
if pcs[i-1].next != pcs[i] {
t.Fatal("pcs[i-1].next != pcs[i]")
}
if ics[i+1].prev != ics[i] {
t.Fatal("ics[i+1].prev != ics[i]")
if pcs[i+1].prev != pcs[i] {
t.Fatal("pcs[i+1].prev != pcs[i]")
}
}
}
Expand Down
Loading

0 comments on commit a7327d8

Please sign in to comment.