goredis

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 6 Imported by: 1

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
}

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(sess *simplesessions.Session, id string) error

Clear clears session in redis.

func (*Store) Commit

func (s *Store) Commit(sess *simplesessions.Session, id string) error

Commit sets all set values

func (*Store) Create

func (s *Store) Create(sess *simplesessions.Session) (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(sess *simplesessions.Session, 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(sess *simplesessions.Session, 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(sess *simplesessions.Session, id string) (map[string]interface{}, error)

GetAll gets all fields from hashmap.

func (*Store) GetMulti

func (s *Store) GetMulti(sess *simplesessions.Session, 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) IsValid

func (s *Store) IsValid(sess *simplesessions.Session, id string) (bool, error)

IsValid checks if the session is set for the id.

func (*Store) Set

func (s *Store) Set(sess *simplesessions.Session, 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