From 96bed882625699543de31995a56622778caadafc Mon Sep 17 00:00:00 2001 From: codewinch <81432659+codewinch@users.noreply.github.com> Date: Sat, 20 Nov 2021 14:02:12 -0600 Subject: [PATCH] Just a quick tip about gob.register --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index c5789cc..dff50f6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,18 @@ import ( "time" ) +func initapp() { + // be sure to register your custom types before calling .CacheFrom() + gob.Register(MyStruct) + gob.Register(MyStruct2) +} + 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 // purges expired items every 10 minutes c := cache.New(5*time.Minute, 10*time.Minute)