func ExampleSet() {
	cacher.Flush()
	ok1 := cacher.Set("key1", []byte("value1"), 0)
	val1, _, _ := cacher.Get("key1")
	fmt.Println(string(val1), ok1)

	ok2 := cacher.Set("key1", []byte("value2"), 0)
	val2, _, _ := cacher.Get("key1")
	fmt.Println(string(val2), ok2)

	// Output:
	// value1 <nil>
	// value2 <nil>
}
func ExampleTouch() {
	cacher.Flush()
	cacher.Set("key1", []byte("value1"), 1)
	err := cacher.Touch("key1", 5)
	fmt.Println(err)

	// Output:
	// <nil>
}
func ExampleReplace() {
	cacher.Flush()
	var err error

	err = cacher.Replace("key1", []byte("replacement"), 0)
	fmt.Println(err)

	cacher.Set("key1", []byte("value1"), 0)
	err = cacher.Replace("key1", []byte("replacement"), 0)
	fmt.Println(err)

	// Output:
	// Key `key1` does not exist.
	// <nil>
}
func ExampleDelete() {
	cacher.Flush()
	var err error

	cacher.Set("key1", []byte("value1"), 0)
	err = cacher.Delete("key1")
	fmt.Println(err)

	err = cacher.Delete("non-existing")
	fmt.Println(err)

	// Output:
	// <nil>
	// Key `non-existing` was not found.
}
func ExampleGet() {
	cacher.Flush()
	var value []byte
	var token string
	var err error

	value, token, err = cacher.Get("non-existing")
	fmt.Println(string(value), token, err)

	cacher.Set("key1", []byte("Hello world!"), 0)
	value, token, err = cacher.Get("key1")
	fmt.Println(string(value), token, err)

	// Output:
	// Key `non-existing` does not exist.
	// Hello world! 86fb269d190d2c85f6e0468ceca42a20 <nil>
}
func ExampleDecrement() {
	cacher.Flush()
	cacher.Decrement("key1", 10, 1, 0)
	cacher.Decrement("key1", 10, 3, 0)
	v, _, _ := cacher.Get("key1")

	num, _ := encoding.BytesInt64(v)
	fmt.Println(num)

	cacher.Set("key2", []byte("string value, not decrementable"), 0)
	ok := cacher.Decrement("key2", 0, 5, 0)
	v2, _, _ := cacher.Get("key2")
	fmt.Println(ok, string(v2))

	// Output:
	// 7
	// Value for key `key2` could not be encoded. string value, not decrementable
}
func ExampleCompareAndReplace() {
	cacher.Flush()
	cacher.Set("key1", []byte("hello world"), 0)
	_, token, _ := cacher.Get("key1")

	var err error
	var val []byte
	err = cacher.CompareAndReplace(token+"FALSE", "key1", []byte("replacement1"), 0)
	val, _, _ = cacher.Get("key1")
	fmt.Println(err, string(val))

	err = cacher.CompareAndReplace(token, "key1", []byte("replacement2"), 0)
	val, _, _ = cacher.Get("key1")
	fmt.Println(err, string(val))

	// Output:
	// Key `key1` does not exist. hello world
	// <nil> replacement2
}