sessions: github.com/adam-hanna/sessions/store Index | Files

package store

import "github.com/adam-hanna/sessions/store"

Index

Package Files

service.go service_interface.go service_util.go

Constants

const (
    // DefaultConnectionAddress defines the default connection address of the redis server
    DefaultConnectionAddress = ":6379"
    // DefaultMaxIdleConnections sets the maximum number of idle connections on the redis server
    DefaultMaxIdleConnections = 3
    // DefaultIdleTimeoutDuration sets the maximum duration to wait before closing an idle connection on the redis server
    DefaultIdleTimeoutDuration = 10 * time.Second
)

Variables

var (
    // ErrRetrievingSession is thrown if there was an error, other than an invalid session, retrieving the \
    // session from the store
    ErrRetrievingSession = errors.New("error retrieving session data from store")
)

type Options Uses

type Options struct {
    ConnectionAddress    string
    MaxIdleConnections   int
    MaxActiveConnections int
    IdleTimeoutDuration  time.Duration
}

Options defines the behavior of the session store

type Service Uses

type Service struct {
    // Pool is a redigo *redis.Pool
    Pool *redis.Pool
}

Service is a session store backed by a redis db

func New Uses

func New(options Options) *Service

New returns a new session store connected to a redis db Alternatively, you can build your own redis store with &Service{Pool: yourCustomPool,}

func (*Service) DeleteUserSession Uses

func (s *Service) DeleteUserSession(sessionID string) error

DeleteUserSession deletes a user session from the store

func (*Service) FetchValidUserSession Uses

func (s *Service) FetchValidUserSession(sessionID string) (*user.Session, error)

FetchValidUserSession returns a valid user session or an err if the session has expired or does not exist. \ If a valid session does not exist, this function should return a nil pointer

func (*Service) SaveUserSession Uses

func (s *Service) SaveUserSession(userSession *user.Session) error

SaveUserSession saves a user session in the store

type ServiceInterface Uses

type ServiceInterface interface {
    SaveUserSession(userSession *user.Session) error
    DeleteUserSession(sessionID string) error
    FetchValidUserSession(sessionID string) (*user.Session, error)
}

ServiceInterface defines the behavior of the session store

Package store imports 4 packages (graph) and is imported by 1 packages. Updated 2017-05-07. Refresh now. Tools for package owners.