Browse Source

refactor add newTTLKeyHeap function

Xiang Li 12 years ago
parent
commit
c05df9e3f5
2 changed files with 7 additions and 2 deletions
  1. 1 2
      store/heap_test.go
  2. 6 0
      store/ttl_key_heap.go

+ 1 - 2
store/heap_test.go

@@ -8,8 +8,7 @@ import (
 )
 
 func TestHeapPushPop(t *testing.T) {
-	h := &TTLKeyHeap{Map: make(map[*Node]int)}
-	heap.Init(h)
+	h := newTTLKeyHeap()
 
 	// add from older expire time to earlier expire time
 	// the path is equal to ttl from now

+ 6 - 0
store/ttl_key_heap.go

@@ -10,6 +10,12 @@ type TTLKeyHeap struct {
 	Map   map[*Node]int
 }
 
+func newTTLKeyHeap() *TTLKeyHeap {
+	h := &TTLKeyHeap{Map: make(map[*Node]int)}
+	heap.Init(h)
+	return h
+}
+
 func (h TTLKeyHeap) Len() int {
 	return len(h.Array)
 }