|
|
@ -53,11 +53,10 @@ Usage:
|
|
|
|
...
|
|
|
|
...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
If you store a reference type like a pointer, slice, map or channel, you do not need to
|
|
|
|
// If you store a reference type like a pointer, slice, map or channel, you do not need to
|
|
|
|
run Set if you modify the underlying data. The cache does not serialize its data, so if
|
|
|
|
// run Set if you modify the underlying data. The cache does not serialize its data, so if
|
|
|
|
you modify a struct whose pointer you've stored in the cache, retrieving that pointer
|
|
|
|
// you modify a struct whose pointer you've stored in the cache, retrieving that pointer
|
|
|
|
with Get will point you to the same data:
|
|
|
|
// with Get will point you to the same data:
|
|
|
|
|
|
|
|
|
|
|
|
foo := &MyStruct{Num: 1}
|
|
|
|
foo := &MyStruct{Num: 1}
|
|
|
|
c.Set("foo", foo, 0)
|
|
|
|
c.Set("foo", foo, 0)
|
|
|
|
...
|
|
|
|
...
|
|
|
@ -71,7 +70,7 @@ with Get will point you to the same data:
|
|
|
|
foo := x.(MyStruct)
|
|
|
|
foo := x.(MyStruct)
|
|
|
|
foo.Println(foo.Num)
|
|
|
|
foo.Println(foo.Num)
|
|
|
|
|
|
|
|
|
|
|
|
will print:
|
|
|
|
// will print:
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
|
|