(client memcache.Client)
| 42 | } |
| 43 | |
| 44 | func clientExample(client memcache.Client) { |
| 45 | version := func() { |
| 46 | resp := client.Version() |
| 47 | fmt.Println("Version") |
| 48 | for i, v := range resp.Versions() { |
| 49 | fmt.Println(" Shard", i, "Version", v) |
| 50 | } |
| 51 | fmt.Println(" Status:", resp.Status()) |
| 52 | if resp.Error() != nil { |
| 53 | fmt.Println(" Error:", resp.Error()) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | verbosity := func(v uint32) { |
| 58 | resp := client.Verbosity(v) |
| 59 | fmt.Println("Verbosity") |
| 60 | fmt.Println(" Status:", resp.Status()) |
| 61 | if resp.Error() != nil { |
| 62 | fmt.Println(" Error:", resp.Error()) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | stats := func(key string) { |
| 67 | resp := client.Stat(key) |
| 68 | fmt.Println("Stats:", key) |
| 69 | for i, s := range resp.Entries() { |
| 70 | fmt.Println(" Shard", i) |
| 71 | for k, v := range s { |
| 72 | fmt.Println(" ", k, ":", v) |
| 73 | } |
| 74 | } |
| 75 | fmt.Println(" Status:", resp.Status()) |
| 76 | if resp.Error() != nil { |
| 77 | fmt.Println(" Error:", resp.Error()) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | flush := func() { |
| 82 | resp := client.Flush(0) |
| 83 | fmt.Println("Flush") |
| 84 | fmt.Println(" Status:", resp.Status()) |
| 85 | if resp.Error() != nil { |
| 86 | fmt.Println(" Error:", resp.Error()) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | get := func(key string) uint64 { |
| 91 | resp := client.Get(key) |
| 92 | fmt.Println("Get", resp.Key()) |
| 93 | fmt.Println(" Status:", resp.Status()) |
| 94 | fmt.Println(" Value:", string(resp.Value())) |
| 95 | fmt.Println(" Flags:", resp.Flags()) |
| 96 | fmt.Println(" CasId:", resp.DataVersionId()) |
| 97 | if resp.Error() != nil { |
| 98 | fmt.Println(" Error:", resp.Error()) |
| 99 | } |
| 100 | |
| 101 | return resp.DataVersionId() |
no test coverage detected