session_redis_store

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GobSerializer

type GobSerializer struct{}

GobSerializer uses gob package to encode the session map

func (GobSerializer) Deserialize

func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error

Deserialize back to map[interface{}]interface{}

func (GobSerializer) Serialize

func (s GobSerializer) Serialize(ss *sessions.Session) (dt []byte, err error)

Serialize using gob

type IStore

type IStore interface {
	sessions.Store
}

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer encode the session map to JSON.

func (JSONSerializer) Deserialize

func (s JSONSerializer) Deserialize(d []byte, ss *sessions.Session) (err error)

Deserialize back to map[string]interface{}

func (JSONSerializer) Serialize

func (s JSONSerializer) Serialize(ss *sessions.Session) (dt []byte, err error)

Serialize to JSON. Will err if there are unmarshalable key values

type SessionSerializer

type SessionSerializer interface {
	Deserialize(d []byte, ss *sessions.Session) error
	Serialize(ss *sessions.Session) ([]byte, error)
}

SessionSerializer provides an interface hook for alternative serializers

type Store

type Store struct {
	Codecs []securecookie.Codec

	DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session
	// contains filtered or unexported fields
}

Store stores sessions in a redis backend.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying *redis.Pool

func (*Store) Delete

func (s *Store) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) (err error)

Delete removes the session from redis, and sets the cookie to expire.

WARNING: This method should be considered deprecated since it is not exposed via the gorilla/sessions interface. Set session.Options.MaxAge = -1 and call Save instead. - July 18th, 2013

func (*Store) Get

func (s *Store) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry. See gorilla/sessions FilesystemStore.Get().

func (*Store) New

func (s *Store) New(r *http.Request, name string) (sess *sessions.Session, err error)

New returns a session for the given name without adding it to the registry. See gorilla/sessions FilesystemStore.New().

func (*Store) Options

func (s *Store) Options(options sssions.Options)

func (*Store) Save

func (s *Store) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) (err error)

Save adds a single session to the response.

Jump to

Keyboard shortcuts

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