Skip to content

Commit

Permalink
add ExampleCache_Clear (#3310)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldme-git committed Feb 27, 2024
1 parent d64a31f commit a1a9465
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions os/gcache/gcache_z_example_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,23 @@ func ExampleCache_Removes() {
// map[k4:v4]
}

func ExampleCache_Clear() {
// Create a cache object,
// Of course, you can also easily use the gcache package method directly
c := gcache.New()

c.SetMap(ctx, g.MapAnyAny{"k1": "v1", "k2": "v2", "k3": "v3", "k4": "v4"}, 0)

// clears all data of the cache.
c.Clear(ctx)

data, _ := c.Data(ctx)
fmt.Println(data)

// Output:
// map[]
}

func ExampleCache_MustGet() {
// Intercepting panic exception information
// err is empty, so panic is not performed
Expand Down

0 comments on commit a1a9465

Please sign in to comment.