Session Ledis Store

安装

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

Example

  1. package main
  2. import (
  3. "github.com/lunny/tango"
  4. "github.com/tango-contrib/session"
  5. "github.com/tango-contrib/session-ledis"
  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. o.Use(session.New(session.Options{
  17. Store: redistore.New(ledistore.Options{
  18. Host: "127.0.0.1",
  19. DbIndex: 0,
  20. MaxAge: 30 * time.Minute,
  21. }),
  22. }))
  23. o.Get("/", new(SessionAction))
  24. }