goredis

package module
v9.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error codes for store errors. This should match the codes
	// defined in the /simplesessions package exactly.
	ErrInvalidSession = &Err{code: 1, msg: "invalid session"}
	ErrFieldNotFound  = &Err{code: 2, msg: "field not found"}
	ErrAssertType     = &Err{code: 3, msg: "assertion failed"}
	ErrNil            = &Err{code: 4, msg: "nil returned"}
)

Functions

This section is empty.

Types

type Err

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

func (*Err) Code

func (e *Err) Code() int

func (*Err) Error

func (e *Err) Error() string

type Store

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

Store represents redis session store for simple sessions. Each session is stored as redis hashmap.

func New

func New(ctx context.Context, client redis.UniversalClient) *Store

New creates a new Redis store instance.

func (*Store) Bool

func (s *Store) Bool(r interface{}, err error) (bool, error)

Bool returns redis reply as Bool.

func (*Store) Bytes

func (s *Store) Bytes(r interface{}, err error) ([]byte, error)

Bytes returns redis reply as Bytes.

func (*Store) Clear

func (s *Store) Clear(id string) error

Clear clears session in redis.

func (*Store) Commit

func (s *Store) Commit(id string) error

Commit sets all set values.

func (*Store) Create

func (s *Store) Create() (string, error)

Create returns a new session id but doesn't stores it in redis since empty hashmap can't be created.

func (*Store) Delete

func (s *Store) Delete(id string, key string) error

Delete deletes a key from redis session hashmap.

func (*Store) Float64

func (s *Store) Float64(r interface{}, err error) (float64, error)

Float64 returns redis reply as Float64.

func (*Store) Get

func (s *Store) Get(id, key string) (interface{}, error)

Get gets a field in hashmap. If field is nill then ErrFieldNotFound is raised

func (*Store) GetAll

func (s *Store) GetAll(id string) (map[string]interface{}, error)

GetAll gets all fields from hashmap.

func (*Store) GetMulti

func (s *Store) GetMulti(id string, keys ...string) (map[string]interface{}, error)

GetMulti gets a map for values for multiple keys. If key is not found then its set as nil.

func (*Store) Int

func (s *Store) Int(r interface{}, err error) (int, error)

Int returns redis reply as integer.

func (*Store) Int64

func (s *Store) Int64(r interface{}, err error) (int64, error)

Int64 returns redis reply as Int64.

func (*Store) Set

func (s *Store) Set(id, key string, val interface{}) error

Set sets a value to given session but stored only on commit

func (*Store) SetPrefix

func (s *Store) SetPrefix(val string)

SetPrefix sets session id prefix in backend

func (*Store) SetTTL

func (s *Store) SetTTL(d time.Duration)

SetTTL sets TTL for session in redis.

func (*Store) String

func (s *Store) String(r interface{}, err error) (string, error)

String returns redis reply as String.

func (*Store) UInt64

func (s *Store) UInt64(r interface{}, err error) (uint64, error)

UInt64 returns redis reply as UInt64.

Jump to

Keyboard shortcuts

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