()
| 60 | } |
| 61 | |
| 62 | func ExampleClient_str() { |
| 63 | ctx := context.Background() |
| 64 | |
| 65 | rdb := redis.NewClient(&redis.Options{ |
| 66 | Addr: "localhost:6379", |
| 67 | Password: "", // no password docs |
| 68 | DB: 0, // use default DB |
| 69 | }) |
| 70 | |
| 71 | // REMOVE_START |
| 72 | // start with fresh database |
| 73 | rdb.FlushDB(ctx) |
| 74 | rdb.Del(ctx, "bike") |
| 75 | // REMOVE_END |
| 76 | |
| 77 | _, err := rdb.JSONSet(ctx, "bike", "$", |
| 78 | "\"Hyperion\"", |
| 79 | ).Result() |
| 80 | |
| 81 | if err != nil { |
| 82 | panic(err) |
| 83 | } |
| 84 | |
| 85 | // STEP_START str |
| 86 | res4, err := rdb.JSONStrLen(ctx, "bike", "$").Result() |
| 87 | |
| 88 | if err != nil { |
| 89 | panic(err) |
| 90 | } |
| 91 | |
| 92 | fmt.Println(*res4[0]) // >>> 8 |
| 93 | |
| 94 | res5, err := rdb.JSONStrAppend(ctx, "bike", "$", "\" (Enduro bikes)\"").Result() |
| 95 | |
| 96 | if err != nil { |
| 97 | panic(err) |
| 98 | } |
| 99 | |
| 100 | fmt.Println(*res5[0]) // >>> 23 |
| 101 | |
| 102 | res6, err := rdb.JSONGet(ctx, "bike", "$").Result() |
| 103 | |
| 104 | if err != nil { |
| 105 | panic(err) |
| 106 | } |
| 107 | |
| 108 | fmt.Println(res6) // >>> ["Hyperion (Enduro bikes)"] |
| 109 | // STEP_END |
| 110 | |
| 111 | // Output: |
| 112 | // 8 |
| 113 | // 23 |
| 114 | // ["Hyperion (Enduro bikes)"] |
| 115 | } |
| 116 | |
| 117 | func ExampleClient_num() { |
| 118 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…