Session NoDB Store

安装

  1. go get github.com/tango-contrib/session-nodb

Example

  1. package main
  2. import (
  3. "github.com/lunny/tango"
  4. "github.com/tango-contrib/session"
  5. "github.com/tango-contrib/session-nodb"
  6. )
  7. type SessionAction struct {
  8. session.Session
  9. }
  10. func (a *SessionAction) Get() string {
  11. a.Session.Set("test", "1")
  12. return a.Session.Get("test").(string)
  13. }
  14. func main() {
  15. o := tango.Classic()
  16. store, _ := nodbstore.New(nodbstore.Options{
  17. Path: "./nodbstore",
  18. DbIndex: 0,
  19. MaxAge: 30 * time.Minute,
  20. })
  21. o.Use(session.New(session.Options{
  22. Store: store,
  23. }))
  24. o.Get("/", new(SessionAction))
  25. }