redis

package
v0.0.0-...-9d85d00 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

func NewStore

func NewStore(client redis.Cmdable, opts ...StoreOption) *Store

NewStore creates a new instance of the Store struct. It takes a redis.Cmdable client as the first argument and optional StoreOptions as the rest of the arguments. It returns a pointer to the created Store.

func (*Store) Generate

func (s *Store) Generate(ctx context.Context, id string) (session.Session, error)

Generate generates a new session in the store with the given ID. If a session with the same ID already exists, it returns an error. Otherwise, it creates a new session and returns it.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (session.Session, error)

Get retrieves a session from the store based on the provided ID. If the session does not exist, it returns an error.

func (*Store) Refresh

func (s *Store) Refresh(ctx context.Context, id string) error

Refresh updates the expiration time of a session in the store. It takes a context and the session ID as input and returns an error if any.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, id string) error

Remove removes an item from the store based on the provided ID.

type StoreOption

type StoreOption func(store *Store)

StoreOption is a function type for configuring a Store.

func WithExpiration

func WithExpiration(expiration time.Duration) StoreOption

WithExpiration sets the expiration duration for the Store.

func WithPrefix

func WithPrefix(prefix string) StoreOption

WithPrefix is a function that returns a StoreOption function. StoreOption is a function that modifies the behavior of the Store type. This function sets the prefix value of the store to the provided prefix parameter.

Jump to

Keyboard shortcuts

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