aboutsummaryrefslogtreecommitdiff
path: root/weed/operation/lookup_vid_cache_test.go
blob: 9c9e2affbd0a8bd990700c92731625ae2eadae09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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")
	}
}