storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TimeFormatExpiredDate is the default time layout for golang time.Parse.
	TimeFormatExpiredDate = "2006-01-02 15:04:05"
)

List of constants used in this package.

Variables

View Source
var (
	// ErrNilToken specifies that the token passed to the function is nil.
	ErrNilToken = errors.New("token is nil")
)

Functions

This section is empty.

Types

type Hub

type Hub interface {
	Get(ctx context.Context, key string) (token *Token, err error)
	Save(ctx context.Context, key string, token *Token) (err error)
}

Hub specifies the contract to interact with the storage provider.

func NewGoRedisV8

func NewGoRedisV8(c *redis.Client) (h Hub)

NewGoRedisV8 creates a new redis client for storage.Hub.

func NewLocalStorage

func NewLocalStorage() Hub

NewLocalStorage creates a new local storage to store the token.

type Token

type Token struct {
	Data        string
	Duration    time.Duration
	ExpiredDate time.Time
}

Token specifies the token data.

func (*Token) IsExpired

func (t *Token) IsExpired(now time.Time) bool

IsExpired checks whether the token is expired.

func (*Token) SetHalfExpiredDate

func (t *Token) SetHalfExpiredDate(now time.Time) *Token

SetHalfExpiredDate sets the expired date to the half of the duration.

Jump to

Keyboard shortcuts

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