Пример #1
0
func main() {

	// keyETCD, cfgETCD, _myFuncGetDataForCache are required
	fmt.Printf("Start etcdaero.New\n")
	et, err := etcdaero.New(keyETCD, cfgETCD, _myFuncGetDataForCache, "my-add-param", "my-add-param-too")
	if err != nil {
		log.Fatal(err)
	}

	/*
		Starts aerospike reader.
		Default result is map[string]interface{}.
		If we need a post-processing after aerospike we
		have to use etcdaero.StartAeroReader( keyETCD, etcdaero.IAeroBody ).
		See example/exam2.go & example/src/storage/storage.go for more details.
	*/
	fmt.Printf("Starts aerospike reader.\n")
	etcdaero.StartAeroReader(keyETCD)

	// just for test
	et.SetTTL(4 * time.Second)

	// here we're making something
	time.Sleep(25 * time.Second)

	/*
		Get data from local cache.
		If we use etcdaero.IAeroBody we can get data with params
		ex: etcdaero.GetAero(keyETCD, "key")
		See example/exam2.go & example/src/storage/storage.go for more details.
	*/
	obj, find := etcdaero.GetAero(keyETCD)
	fmt.Printf("result from aerospike. FIND: %t, Data: %+v\n", find, obj)
}
Пример #2
0
func main() {

	fmt.Println("Start")
	et, err := etcdaero.New(keyETCD, cfgETCD, _myFuncGetDataForCache, "Winnie", "Pooh", "Honey")
	if err != nil {
		log.Fatal(err)
	}

	etcdaero.StartAeroReader(keyETCD, storage.NewlocalStorage())

	et.SetTTL(4 * time.Second)

	time.Sleep(25 * time.Second)

	key := "ru"
	obj, find := etcdaero.GetAero(keyETCD, key)
	fmt.Printf("result from aerospike. FIND: %t, Data for key %s: %+v\n", find, key, obj)
}