1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00

add ExampleCache_Clear (#3310)

This commit is contained in:
oldme 2024-02-27 19:42:58 +08:00 committed by GitHub
parent d64a31fd1a
commit a1a9465e52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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