redis

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr     string
	Username string
	Password string
	Database int
	// Sore key prefix.
	KeyPrefix string
}

Config contains necessary redis options.

type Store

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

Store redis storage.

func NewStore

func NewStore(cfg *Config) *Store

NewStore create an *Store instance to handle token storage, deletion, and checking.

func (*Store) Check

func (s *Store) Check(ctx context.Context, accessToken string) (bool, error)

Check check if the specified JWT Token exists in Redis.

func (*Store) Close

func (s *Store) Close() error

Close is used to close the redis client.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, accessToken string) (bool, error)

Delete delete the specified JWT Token in Redis.

func (*Store) Set

func (s *Store) Set(ctx context.Context, accessToken string, expiration time.Duration) error

Set call the Redis client to set a key-value pair with an expiration time, where the key name format is <prefix><accessToken>.

Jump to

Keyboard shortcuts

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