Closed cjcjameson closed 6 years ago
Reflection is rather costly and wont fit many applications performance requirements. Choice between reflection vs type assert is a no brainer.
I am thinking about unsafe pointers. Cast is probably cheaper. See, for example, https://golang.org/pkg/runtime/?m=all#noescape
A naive implementation of a memory pool https://github.com/larytet/mcachego/blob/master/unsafepool/unsafepool_test.go
Hi there, hearing about the project for the first time. I can see how powerful an un-typed cache would be. I'm just curious if folks have ever looked into making the cache typed -- you pass the type in as an argument at the beginning, and there's some pro-flection (anti-reflection) / metaprogramming under the hood.
Or maybe wrapper methods on look-up that enforce type-safety? Either way, something that reduces the burden on the caller to cast their looked-up values. Maybe if a use-case wanted type-safety, they'd implement their own wrapper method.