Just a quick tip about gob.register
This commit is contained in:
parent
46f4078530
commit
96bed88262
11
README.md
11
README.md
|
@ -26,7 +26,18 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initapp() {
|
||||||
|
// be sure to register your custom types before calling .CacheFrom()
|
||||||
|
gob.Register(MyStruct)
|
||||||
|
gob.Register(MyStruct2)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
// only needed if you are loading to/from external storage
|
||||||
|
// with .Items() and .CacheFrom()
|
||||||
|
initapp()
|
||||||
|
|
||||||
// Create a cache with a default expiration time of 5 minutes, and which
|
// Create a cache with a default expiration time of 5 minutes, and which
|
||||||
// purges expired items every 10 minutes
|
// purges expired items every 10 minutes
|
||||||
c := cache.New(5*time.Minute, 10*time.Minute)
|
c := cache.New(5*time.Minute, 10*time.Minute)
|
||||||
|
|
Loading…
Reference in New Issue