Re:Decorators in Go using embedded structs
by sethammons on Wednesday October 23, 2019 @03:22PM
(#21337912)
I'd recommend only embedding a mutex on private structs - you likely don't want to expose Lock and Unlock.
That is elegant.
This example looks nice, but I think the naming of the structure and interfaces makes it hard to follow and a cache doesn’t necessarily benefit from it. In fact, it’s worse if your cache isn’t in-memory, and you’re not sharing an instance or a connection pool. If you are, this is just indirection and you can live with `Cache.get` just as well.