db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelAllForUid

func DelAllForUid(ctx context.Context, uid string)

func DelClientIdForUid

func DelClientIdForUid(ctx context.Context, uid string, clientId string)

Types

type DB

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

func Find

func Find(ctx context.Context, uid string, clientId string) (db *DB, ok bool)

func FindAll

func FindAll(ctx context.Context, uid string) []*DB

func New

func New(ctx context.Context, suggestedToken string) *DB

func (*DB) Del

func (db *DB) Del()

Del 可重复多次调用

func (*DB) IsValidToken

func (db *DB) IsValidToken() bool

func (*DB) LastTime

func (db *DB) LastTime() time.Time

func (*DB) OverWrite

func (db *DB) OverWrite(value *Value)

func (*DB) RealToken

func (db *DB) RealToken() string

func (*DB) RefreshTTL

func (db *DB) RefreshTTL()

func (*DB) RefreshTTLAndLastTime

func (db *DB) RefreshTTLAndLastTime(lastTime time.Time)

func (*DB) RefreshTTLto

func (db *DB) RefreshTTLto(ttl time.Duration)

func (*DB) Session

func (db *DB) Session() string

func (*DB) SetOrUseOld

func (db *DB) SetOrUseOld(value *Value)

func (*DB) TTL

func (db *DB) TTL() (ttl time.Duration)

func (*DB) Uid

func (db *DB) Uid() (uid string, ok bool)

func (*DB) Value

func (db *DB) Value() (value *Value, ok bool)

type Value

type Value struct {
	Uid      string
	ClientId string
	// 具体意义由使用方决定传入什么,比如最后通信、最后登录等
	LatestTime time.Time
	Session    string
}

Jump to

Keyboard shortcuts

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