Skip to content

Commit 96426d0

Browse files
authored
README.md: Remove the unprotected change example since it would actually need external synchronization
1 parent dd1ed0b commit 96426d0

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,6 @@ func main() {
7575
foo := x.(*MyStruct)
7676
// ...
7777
}
78-
79-
// If you store a reference type like a pointer, slice, map or channel, you
80-
// do not need to run Set if you modify the underlying data. The cached
81-
// reference points to the same memory, so if you modify a struct whose
82-
// pointer you've stored in the cache, retrieving that pointer with Get will
83-
// point you to the same data:
84-
foo := &MyStruct{Num: 1}
85-
c.Set("foo", foo, cache.DefaultExpiration)
86-
// ...
87-
x, _ := c.Get("foo")
88-
foo := x.(*MyStruct)
89-
fmt.Println(foo.Num)
90-
// ...
91-
foo.Num++
92-
// ...
93-
x, _ := c.Get("foo")
94-
foo := x.(*MyStruct)
95-
foo.Println(foo.Num)
96-
97-
// will print:
98-
// 1
99-
// 2
100-
10178
}
10279
```
10380

0 commit comments

Comments
 (0)