Add volume id lookup caching

This commit is contained in:
Chris Lu
2014-05-25 14:01:54 -07:00
parent 38260fcfb1
commit b5f99b26eb
3 changed files with 84 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
package operation
import (
"fmt"
"testing"
"time"
)
func TestCaching(t *testing.T) {
var (
vc VidCache
)
var locations []Location
locations = append(locations, Location{Url: "a.com:8080"})
vc.Set("123", locations, time.Second)
ret, _ := vc.Get("123")
if ret == nil {
t.Fatal("Not found vid 123")
}
fmt.Printf("vid 123 locations = %v\n", ret)
time.Sleep(2 * time.Second)
ret, _ = vc.Get("123")
if ret != nil {
t.Fatal("Not found vid 123")
}
}