mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
go fmt
This commit is contained in:
@ -131,13 +131,12 @@ func ExampleCache_SetMap() {
|
||||
//It does not expire if `duration` == 0. It deletes the keys of `data` if `duration` < 0 or given `value` is nil.
|
||||
c.SetMap(ctx, data, 1000*time.Millisecond)
|
||||
|
||||
|
||||
//Gets the specified key value
|
||||
v1, _ := c.Get(ctx, "k1")
|
||||
v2, _ := c.Get(ctx, "k2")
|
||||
v3, _ := c.Get(ctx, "k3")
|
||||
|
||||
fmt.Println( v1,v2,v3)
|
||||
fmt.Println(v1, v2, v3)
|
||||
|
||||
// Output:
|
||||
// v1 v2 v3
|
||||
@ -173,14 +172,13 @@ func ExampleCache_Update() {
|
||||
c.SetMap(ctx, g.MapAnyAny{"k1": "v1", "k2": "v2", "k3": "v3"}, 0)
|
||||
|
||||
//Print the current key value pair
|
||||
k1, _ := c.Get(ctx,"k1")
|
||||
k1, _ := c.Get(ctx, "k1")
|
||||
fmt.Println(k1)
|
||||
k2, _ := c.Get(ctx,"k2")
|
||||
k2, _ := c.Get(ctx, "k2")
|
||||
fmt.Println(k2)
|
||||
k3, _ := c.Get(ctx,"k3")
|
||||
k3, _ := c.Get(ctx, "k3")
|
||||
fmt.Println(k3)
|
||||
|
||||
|
||||
//Update updates the value of `key` without changing its expiration and returns the old value.
|
||||
re, exist, _ := c.Update(ctx, "k1", "v11")
|
||||
fmt.Println(re, exist)
|
||||
@ -190,11 +188,11 @@ func ExampleCache_Update() {
|
||||
re1, exist1, _ := c.Update(ctx, "k4", "v44")
|
||||
fmt.Println(re1, exist1)
|
||||
|
||||
kup1, _ := c.Get(ctx,"k1")
|
||||
kup1, _ := c.Get(ctx, "k1")
|
||||
fmt.Println(kup1)
|
||||
kup2, _ := c.Get(ctx,"k2")
|
||||
kup2, _ := c.Get(ctx, "k2")
|
||||
fmt.Println(kup2)
|
||||
kup3, _ := c.Get(ctx,"k3")
|
||||
kup3, _ := c.Get(ctx, "k3")
|
||||
fmt.Println(kup3)
|
||||
// Output:
|
||||
// v1
|
||||
@ -305,13 +303,13 @@ func ExampleCache_Data() {
|
||||
c.Set(ctx, "k5", "v5", 0)
|
||||
|
||||
//Data returns a copy of all key-value pairs in the cache as map type. Note that this function may lead lots of memory usage, you can implement this function if necessary.
|
||||
data, _ := c.Get(ctx,"k1")
|
||||
data, _ := c.Get(ctx, "k1")
|
||||
fmt.Println(data)
|
||||
|
||||
data1, _ := c.Get(ctx,"k2")
|
||||
data1, _ := c.Get(ctx, "k2")
|
||||
fmt.Println(data1)
|
||||
|
||||
data2, _ := c.Get(ctx,"k5")
|
||||
data2, _ := c.Get(ctx, "k5")
|
||||
fmt.Println(data2)
|
||||
|
||||
// Output:
|
||||
@ -482,7 +480,7 @@ func ExampleCache_Removes() {
|
||||
c.SetMap(ctx, g.MapAnyAny{"k1": "v1", "k2": "v2", "k3": "v3", "k4": "v4"}, 0)
|
||||
|
||||
//Remove deletes one or more keys from cache, and returns its value. If multiple keys are given, it returns the value of the last deleted item.
|
||||
c.Removes(ctx, g.Slice{"k1", "k2","k3"})
|
||||
c.Removes(ctx, g.Slice{"k1", "k2", "k3"})
|
||||
|
||||
data, _ := c.Data(ctx)
|
||||
fmt.Println(data)
|
||||
|
||||
Reference in New Issue
Block a user