Update gcache_z_example_cache_test.go

This commit is contained in:
546104865
2021-11-11 22:18:01 +08:00
parent 655426c322
commit 9b663b4c2b

View File

@ -420,6 +420,19 @@ func ExampleCache_Keys() {
}
func ExampleCache_KeyStrings() {
c := gcache.New()
c.SetMap(ctx, g.MapAnyAny{"k1": "v1", "k2": "v2"}, 0)
// KeyStrings returns all keys in the cache as string slice.
keys, _ := c.KeyStrings(ctx)
fmt.Println(keys)
// May Output:
// [k1 k2]
}
func ExampleCache_Remove() {
// Create a cache object,
@ -646,7 +659,7 @@ func ExampleCache_MustKeys() {
c.SetMap(ctx, g.MapAnyAny{"k1": "v1", "k2": "v2"}, 0)
// MustKeys acts like Keys, but it panics if any error occurs.
keys1, _ := c.Keys(ctx)
keys1 := c.MustKeys(ctx)
fmt.Println(keys1)
// May Output: