Skip to content

Implementation of user session written in Go. Session data is stored inside the Redis database.

Notifications You must be signed in to change notification settings

adrian83/go-redis-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-redis-session

Implementation of user session written in Go. Session data is stored inside the Redis database.

USAGE

  1. Import dependency
import "github.com/go-redis/redis"

$ go get github.com/go-redis/redis

  1. Create Redis client
options := &redis.Options{
	Addr:     "redishost:6379",
	Password: "secret",
	DB:       0,
}

client := redis.NewClient(options)
  1. Create Session Store
store := NewStore(client, 3600)
  1. Supported operations
session, err := store.Create(sessionID)

err = store.Delete(sessionID)

err = store.Save(session)

session, err := store.Find(sessionID)

err = session.Add(key, value)

session.Remove(key string)

var name string
err = session.Get(key, &name)

TESTING

  1. Running unit tests: go test ./...
  2. Running integration tests: go test ./... --tags=integration (make sure docker daemon is running)

About

Implementation of user session written in Go. Session data is stored inside the Redis database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages