예제 #1
0
func ExampleFlush() {
	cacher.Flush()
	var errs map[string]error

	keys := []string{"key1", "key2"}
	multi := map[string][]byte{
		"key1": []byte("value1"),
		"key2": []byte("value2"),
	}
	cacher.SetMulti(multi, 0)

	_, _, errs = cacher.GetMulti(keys)
	fmt.Println(errs["key1"], errs["key2"])

	cacher.Flush()
	_, _, errs = cacher.GetMulti(keys)
	fmt.Println(errs["key1"], errs["key2"])

	// Output:
	// <nil> <nil>
	// Key `key1` does not exist. Key `key2` does not exist.
}
예제 #2
0
func ExampleGetMulti() {
	cacher.Flush()
	multi := map[string][]byte{
		"key1": []byte("value1"),
		"key2": []byte("value2"),
	}

	cacher.SetMulti(multi, 0)

	keys := []string{"key1", "key2"}

	values, tokens, bools := cacher.GetMulti(keys)
	fmt.Println(values["key1"], values["key2"])
	fmt.Println(tokens["key1"], tokens["key2"])
	fmt.Println(bools["key1"], bools["key2"])

	// Output:
	// [118 97 108 117 101 49] [118 97 108 117 101 50]
	// 9946687e5fa0dab5993ededddb398d2e f066ce9385512ee02afc6e14d627e9f2
	// <nil> <nil>
}