Managing your HTTP session using Redis
While working with the distributed applications, we probably have to implement stateless load balancing for frontend users. This is so we can persist session information in a database or a filesystem so that we can identify the user and retrieve their information if a server gets shut down or restarted.
We will be solving this problem as part of the recipe using Redis as the persistent store to save a session.
Getting ready…
As we have already created a session variable in our previous recipe using the Gorilla cookie store, we will just extend this recipe to save session information in Redis rather than maintaining it on the server.
There are multiple implementations of the Gorilla session store, which you can find at https://github.com/gorilla/sessions#store-implementations
. As we are using Redis as our backend store, we will be using https://github.com/boj/redistore
, which depends on the Redigo Redis library to store a session.
This recipe assumes you...