On 29 June 2011 13:51, Brad Fitzpatrick <brad...@golang.org> wrote:
> I wrote a memcache client library:
> https://github.com/bradfitz/gomemcache/
Firstly, thanks for this. I have been experimenting with it, but just
looking to figure out the best idiomatic way to use it in a webapp.
My first take on it was to create the memcache client inside each
request (just to get it working), but this isn't the best way. So I
figured I'd just stick it as a global which my handlers could see ...
in other languages this has served me well. Finally I came upon the
init() function, so ended up with something like the following. Does
this look like a remotely decent way of doing this, or is there a
better suggestion from anyone else?
* https://gist.github.com/1144739
Note: the reason I figured it was ok to put it as a global is because
in the docs it says that the Memcache Client is "... safe for unlocked
use by multiple concurrent goroutines". Am I correct in presuming
doing it this way is safe?
Many thanks,
Andy
--
contact: Andrew Chilton
website: http://www.chilts.org/blog/
Firstly, thanks for this. I have been experimenting with it, but just
looking to figure out the best idiomatic way to use it in a webapp.
My first take on it was to create the memcache client inside each
request (just to get it working), but this isn't the best way.
So I
figured I'd just stick it as a global which my handlers could see ...
in other languages this has served me well. Finally I came upon the
init() function, so ended up with something like the following. Does
this look like a remotely decent way of doing this, or is there a
better suggestion from anyone else?
* https://gist.github.com/1144739
Note: the reason I figured it was ok to put it as a global is because
in the docs it says that the Memcache Client is "... safe for unlocked
use by multiple concurrent goroutines". Am I correct in presuming
doing it this way is safe?