https://github.com/no-src/redistore
A session store backend for gorilla/sessions using Redis.
https://github.com/no-src/redistore
Last synced: 3 months ago
JSON representation
A session store backend for gorilla/sessions using Redis.
- Host: GitHub
- URL: https://github.com/no-src/redistore
- Owner: no-src
- License: mit
- Created: 2023-06-06T13:54:57.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-09-09T05:18:57.000Z (10 months ago)
- Last Synced: 2025-09-09T08:19:18.205Z (10 months ago)
- Language: Go
- Size: 98.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redistore
[](https://github.com/no-src/redistore/actions)
[](https://github.com/no-src/redistore/blob/main/LICENSE)
[](https://pkg.go.dev/github.com/no-src/redistore)
[](https://goreportcard.com/report/github.com/no-src/redistore)
[](https://codecov.io/gh/no-src/redistore)
[](https://github.com/no-src/redistore/releases)
A session store backend
for [gorilla/sessions](http://www.gorillatoolkit.org/pkg/sessions) - [src](https://github.com/gorilla/sessions).
The redistore project is a fork of [redistore](https://github.com/boj/redistore).
The purpose of this fork is to replace the [redigo](https://github.com/gomodule/redigo)
with [go-redis](https://github.com/redis/go-redis) as the driver of redis store.
## Requirements
Depends on the [go-redis](https://github.com/redis/go-redis) Redis library.
## Installation
```bash
go get -u github.com/no-src/redistore
```
## Documentation
Available on [pkg.go.dev](https://pkg.go.dev/github.com/no-src/redistore).
See https://github.com/gorilla/sessions for full documentation on underlying interface.
### Example
``` go
// 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)
```