Skip to content

Commit

Permalink
refactor add newTTLKeyHeap function
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Nov 5, 2013
1 parent b9593b8 commit c05df9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions store/heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions store/ttl_key_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit c05df9e

Please sign in to comment.