Add en/0.6.x.md syntax highlighting

This commit is contained in:
vCaesar
2017-05-20 17:56:20 +08:00
parent 919364cfe3
commit 19c6592848
4 changed files with 45 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
# 6.3 Session storage
We introduced a simple session manager's working principles in the previous section, and among other things, we defined a session storage interface. In this section, I'm going to show you an example of a memory based session storage engine that implements this interface. You can tailor this to other forms of session storage as well.
```Go
package memory
import (
@@ -114,16 +114,16 @@ We introduced a simple session manager's working principles in the previous sect
session.Register("memory", pder)
}
```
The above example implements a memory based session storage mechanism. It uses its `init()` function to register this storage engine to the session manager. So how do we register this engine from our main program?
```Go
import (
"github.com/astaxie/session"
_ "github.com/astaxie/session/providers/memory"
)
```
We use the blank import mechanism (which will invoke the package's `init()` function automatically) to register this engine to a session manager. We then use the following code to initialize the session manager:
```Go
var globalSessions *session.Manager
// initialize in init() function
@@ -131,7 +131,7 @@ We use the blank import mechanism (which will invoke the package's `init()` func
globalSessions, _ = session.NewManager("memory", "gosessionid", 3600)
go globalSessions.GC()
}
```
## Links
- [Directory](preface.md)