mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
e8a4d30139
Former-commit-id: 900e1a398fd82aa1cea4f319e89b8088dd81cf6c [formerly f172c22b12c49c0291e0d986dc4af94fcc91d192] [formerly 43c5da81442a5f0ca79a6eabb1dfdfbfb3f22680 [formerly
|
||
---|---|---|
.. | ||
.gitignore | ||
doc.go | ||
LICENSE | ||
README.md | ||
redistore.go |
redistore
A session store backend for gorilla/sessions - src.
Requirements
Depends on the Redigo Redis library.
Installation
go get gopkg.in/boj/redistore.v1
Documentation
Available on godoc.org.
See http://www.gorillatoolkit.org/pkg/sessions for full documentation on underlying interface.
Example
// Fetch new store.
store, err := NewRediStore(10, "tcp", ":6379", "", []byte("secret-key"))
if err != nil {
panic(err)
}
defer store.Close()
// Get a session.
session, err = store.Get(req, "session-key")
if err != nil {
log.Error(err.Error())
}
// Add a value.
session.Values["foo"] = "bar"
// Save.
if err = sessions.Save(req, rsp); err != nil {
t.Fatalf("Error saving session: %v", err)
}
// Delete session.
session.Options.MaxAge = -1
if err = sessions.Save(req, rsp); err != nil {
t.Fatalf("Error saving session: %v", err)
}
// Change session storage configuration for MaxAge = 10 days.
store.SetMaxAge(10*24*3600)