boltstore/README.md

55 lines
993 B
Markdown
Raw Normal View History

2014-06-13 22:50:18 +04:00
# BoltStore
2014-06-13 13:46:18 +04:00
2014-06-13 22:45:15 +04:00
[![GoDoc](https://godoc.org/github.com/yosssi/boltstore?status.png)](https://godoc.org/github.com/yosssi/boltstore)
2014-06-13 22:49:20 +04:00
2014-06-13 22:50:18 +04:00
## About
BoltStore is a session store backend for [gorilla/sessions](https://github.com/gorilla/sessions) using [Bolt](https://github.com/boltdb/bolt).
2014-06-13 22:49:20 +04:00
## Installation
```go
2014-06-13 22:50:42 +04:00
go get github.com/yosssi/boltstore/...
2014-06-13 22:49:20 +04:00
```
## Example
```go
// Fetch new store.
store, err := boltstore.New(
boltstore.Config{
SessionOptions: sessions.Options{
MaxAge: 60 * 60 * 24 * 30, // 30days
},
},
[]byte("secret-key"),
)
if err != nil {
panic(err)
}
defer store.Close()
// Get a session.
2014-06-13 22:53:38 +04:00
session, err := store.Get(r, "session-key")
2014-06-13 22:49:20 +04:00
if err != nil {
panic(err)
}
// Add a value.
session.Values["foo"] = "bar"
// Save.
if err := sessions.Save(r, w); err != nil {
panic(err)
}
2014-06-13 22:51:33 +04:00
// Delete the session.
2014-06-13 22:49:20 +04:00
session.Options.MaxAge = -1
if err := sessions.Save(r, w); err != nil {
panic(err)
}
```
## Documentation
* [GoDoc](http://godoc.org/github.com/yosssi/boltstore)