Session SSDB Store

安装

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

Example

  1. package main
  2. import (
  3. "github.com/lunny/tango"
  4. "github.com/tango-contrib/session"
  5. "github.com/tango-contrib/session-ssdb"
  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, err := ssdbstore.New(redistore.Options{
  17. Host: "127.0.0.1",
  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. }