redisstore

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2020 License: MIT Imports: 8 Imported by: 0

README

sessionup-redisstore

Build status GoDoc

Redis session store implementation for sessionup

Installation

go get github.com/swithek/sessionup-redisstore

Usage

Create and activate a new RedisStore:

// create redigo connection pool
pool := &redis.Pool{
    Dial: func() (redis.Conn, error) {
         return redis.Dial("tcp", "localhost:6379")
    },
}

store, err := redisstore.New(pool, "customers")
if err != nil {
      // handle error
}

manager := sessionup.NewManager(store)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore is a Redis implementation of sessionup.Store.

func New

func New(pool *redis.Pool, prefix string) *RedisStore

New returns a fresh instance of RedisStore. prefix parameter determines the prefix that will be used for each session key (might be empty string). Useful when working with multiple session managers.

func (*RedisStore) Create

func (r *RedisStore) Create(ctx context.Context, s sessionup.Session) error

Create inserts the provided session into the store and ensures that it is deleted when expiration time due.

func (*RedisStore) DeleteByID

func (r *RedisStore) DeleteByID(ctx context.Context, id string) error

DeleteByID deletes the session from the store by the provided ID. If session is not found, this function will be no-op.

func (*RedisStore) DeleteByUserKey

func (r *RedisStore) DeleteByUserKey(ctx context.Context, key string, expIDs ...string) error

DeleteByUserKey deletes all sessions associated with the provided user key, except those whose IDs are provided as the last argument. If none are found, this function will no-op.

func (*RedisStore) FetchByID

func (r *RedisStore) FetchByID(ctx context.Context, id string) (sessionup.Session, bool, error)

FetchByID retrieves a session from the store by the provided ID. The second returned value indicates whether the session was found or not (true == found), error should will be nil if session is not found.

func (*RedisStore) FetchByUserKey

func (r *RedisStore) FetchByUserKey(ctx context.Context, key string) ([]sessionup.Session, error)

FetchByUserKey retrieves all sessions associated with the provided user key. If none are found, both return values will be nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL