redistore

package module
v0.0.0-...-213f26f Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 12 Imported by: 0

README

gorilla-session-redis-store

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultRandomKeyGenerator

type DefaultRandomKeyGenerator struct {
}

func (*DefaultRandomKeyGenerator) GenerateKey

func (g *DefaultRandomKeyGenerator) GenerateKey() (string, error)

type GoRedisV9Client

type GoRedisV9Client struct {
	Client *redis.Client
}

func (*GoRedisV9Client) Close

func (c *GoRedisV9Client) Close(ctx context.Context) error

func (*GoRedisV9Client) Del

func (c *GoRedisV9Client) Del(ctx context.Context, key *SessionKey) error

func (*GoRedisV9Client) Get

func (c *GoRedisV9Client) Get(ctx context.Context, key *SessionKey) ([]byte, bool, error)

func (*GoRedisV9Client) Set

func (c *GoRedisV9Client) Set(ctx context.Context, key *SessionKey, data []byte, expiration time.Duration) error

func (*GoRedisV9Client) SetNX

func (c *GoRedisV9Client) SetNX(ctx context.Context, key *SessionKey, data []byte, expiration time.Duration) (bool, error)

type JSONSerde

type JSONSerde interface {
	Marshal(ctx context.Context, session *sessions.Session) ([]byte, error)
	Unmarshal(ctx context.Context, serialized []byte, session *sessions.Session) error
}

type JSONSerializer

type JSONSerializer struct {
	JSONSerde JSONSerde
}

func (JSONSerializer) Deserialize

func (s JSONSerializer) Deserialize(ctx context.Context, serialized []byte, session *sessions.Session) error

func (JSONSerializer) Serialize

func (s JSONSerializer) Serialize(ctx context.Context, session *sessions.Session) ([]byte, error)

type KeyGenerator

type KeyGenerator interface {
	GenerateKey() (string, error)
}

type RedisClient

type RedisClient interface {
	Get(ctx context.Context, key *SessionKey) ([]byte, bool, error)
	Set(ctx context.Context, key *SessionKey, data []byte, expiration time.Duration) error
	SetNX(ctx context.Context, key *SessionKey, data []byte, expiration time.Duration) (bool, error)
	Del(ctx context.Context, key *SessionKey) error
	Close(ctx context.Context) error
}

type Redistore

type Redistore struct {
	RedisClient       RedisClient
	Options           sessions.Options
	KeyGenerator      KeyGenerator
	KeyPrefix         string
	Serializer        Serializer
	NoWaitWritingMode bool
}

func MakeDefaultWithGoRedisV9

func MakeDefaultWithGoRedisV9(goRedisV9Client *redis.Client) *Redistore

func (*Redistore) Close

func (s *Redistore) Close(ctx context.Context) error

Close closes the Redis store

func (*Redistore) Get

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

Get returns a session for the given name after adding it to the registry.

func (*Redistore) New

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

New returns a session for the given name without adding it to the registry.

func (*Redistore) Save

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

type Serializer

type Serializer interface {
	Serialize(context.Context, *sessions.Session) ([]byte, error)
	Deserialize(context.Context, []byte, *sessions.Session) error
}

type SessionKey

type SessionKey struct {
	KeyPrefix string
	SessionID string
}

func (*SessionKey) ToString

func (k *SessionKey) ToString() string

Jump to

Keyboard shortcuts

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