persist

package
v0.1.81 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {

	// GetStr string operate string value
	GetStr(key string) string
	// SetStr set store value and timeout
	SetStr(key string, value string, timeout int64) error
	// UpdateStr only update value
	UpdateStr(key string, value string) error
	// DeleteStr delete string value
	DeleteStr(key string) error
	// GetStrTimeout get expire
	GetStrTimeout(key string) int64
	// UpdateStrTimeout update expire time
	UpdateStrTimeout(key string, timeout int64) error

	// Get returns interface{}
	// If serializer != nil, need to input reflect.Type, used to serializer to deserialize,
	// if ( serializer == nil || t == nil || len(t) == 0 ), returns value directly.
	Get(key string, t ...reflect.Type) interface{}
	// Set store interface{}
	Set(key string, value interface{}, timeout int64) error
	// Update only update interface{} value
	Update(key string, value interface{}) error
	// Delete delete interface{} value
	Delete(key string) error
	// GetTimeout get expire
	GetTimeout(key string) int64
	// UpdateTimeout update timeout
	UpdateTimeout(key string, timeout int64) error

	// SetSerializer used to serialize and deserialize
	// Serialize when call Set() or Update(), deserialize when call Get(key,t)
	SetSerializer(serializer Serializer)
}

type BatchAdapter

type BatchAdapter interface {
	Adapter
	// DeleteBatchFilteredKey delete data by keyPrefix
	DeleteBatchFilteredKey(filterKeyPrefix string) error
	// GetCountsFilteredKey get data by keyPrefix
	GetCountsFilteredKey(filterKeyPrefix string) (int, error)
}

type CountWatcher added in v0.1.7

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

func NewCountWatcher added in v0.1.7

func NewCountWatcher() *CountWatcher

func (*CountWatcher) Ban added in v0.1.7

func (c *CountWatcher) Ban(loginType string, id interface{}, service string, level int, time int64)

func (*CountWatcher) CloseSafe added in v0.1.7

func (c *CountWatcher) CloseSafe(loginType string, token string, service string)

func (*CountWatcher) GetLoginCounts added in v0.1.7

func (c *CountWatcher) GetLoginCounts() int64

func (*CountWatcher) Kickout added in v0.1.7

func (c *CountWatcher) Kickout(loginType string, id interface{}, tokenValue string)

func (*CountWatcher) Login added in v0.1.7

func (c *CountWatcher) Login(loginType string, id interface{}, tokenValue string, loginModel *model.Login)

func (*CountWatcher) Logout added in v0.1.7

func (c *CountWatcher) Logout(loginType string, id interface{}, tokenValue string)

func (*CountWatcher) OpenSafe added in v0.1.7

func (c *CountWatcher) OpenSafe(loginType string, token string, service string, time int64)

func (*CountWatcher) RefreshToken added in v0.1.7

func (c *CountWatcher) RefreshToken(tokenValue string, id interface{}, timeout int64)

func (*CountWatcher) Replace added in v0.1.7

func (c *CountWatcher) Replace(loginType string, id interface{}, tokenValue string)

func (*CountWatcher) UnBan added in v0.1.7

func (c *CountWatcher) UnBan(loginType string, id interface{}, service string)

type Counter added in v0.1.7

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

func (*Counter) Count added in v0.1.7

func (c *Counter) Count() int64

func (*Counter) Decrement added in v0.1.7

func (c *Counter) Decrement()

func (*Counter) Increment added in v0.1.7

func (c *Counter) Increment()

type DefaultAdapter

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

func NewDefaultAdapter

func NewDefaultAdapter() *DefaultAdapter

func NewJsonAdapter added in v0.0.4

func NewJsonAdapter() *DefaultAdapter

func (*DefaultAdapter) Delete

func (d *DefaultAdapter) Delete(key string) error

func (*DefaultAdapter) DeleteBatchFilteredKey

func (d *DefaultAdapter) DeleteBatchFilteredKey(keyPrefix string) error

func (*DefaultAdapter) DeleteStr

func (d *DefaultAdapter) DeleteStr(key string) error

func (*DefaultAdapter) EnableCleanTimer added in v0.1.2

func (d *DefaultAdapter) EnableCleanTimer(b bool)

func (*DefaultAdapter) Get

func (d *DefaultAdapter) Get(key string, t ...reflect.Type) interface{}

func (*DefaultAdapter) GetCleanTimer added in v0.1.3

func (d *DefaultAdapter) GetCleanTimer() bool

func (*DefaultAdapter) GetCountsFilteredKey added in v0.1.7

func (d *DefaultAdapter) GetCountsFilteredKey(keyPrefix string) (int, error)

func (*DefaultAdapter) GetStr

func (d *DefaultAdapter) GetStr(key string) string

GetStr if key is expired delete it before get data

func (*DefaultAdapter) GetStrTimeout

func (d *DefaultAdapter) GetStrTimeout(key string) int64

func (*DefaultAdapter) GetTimeout

func (d *DefaultAdapter) GetTimeout(key string) int64

func (*DefaultAdapter) Set

func (d *DefaultAdapter) Set(key string, value interface{}, timeout int64) error

func (*DefaultAdapter) SetCache added in v0.1.7

func (d *DefaultAdapter) SetCache(cache cache.Cache)

func (*DefaultAdapter) SetSerializer added in v0.0.8

func (d *DefaultAdapter) SetSerializer(serializer Serializer)

func (*DefaultAdapter) SetStr

func (d *DefaultAdapter) SetStr(key string, value string, timeout int64) error

func (*DefaultAdapter) StartCleanTimer

func (d *DefaultAdapter) StartCleanTimer(period int64) error

func (*DefaultAdapter) Update

func (d *DefaultAdapter) Update(key string, value interface{}) error

func (*DefaultAdapter) UpdateStr

func (d *DefaultAdapter) UpdateStr(key string, value string) error

func (*DefaultAdapter) UpdateStrTimeout

func (d *DefaultAdapter) UpdateStrTimeout(key string, timeout int64) error

func (*DefaultAdapter) UpdateTimeout

func (d *DefaultAdapter) UpdateTimeout(key string, timeout int64) error

type Dispatcher added in v0.1.6

type Dispatcher interface {

	// SetAllStr store string in all instances
	SetAllStr(key string, value string, timeout int64) error
	// UpdateAllStr only update string value in all instances
	UpdateAllStr(key string, value string) error

	// SetAll store interface{} in all instances
	SetAll(key string, value interface{}, timeout int64) error
	// UpdateAll only update interface{} value in all instances
	UpdateAll(key string, value interface{}) error

	// DeleteAll delete interface{} value in all instances
	DeleteAll(key string) error
	// UpdateAllTimeout update timeout in all instances
	UpdateAllTimeout(key string, timeout int64) error
}

type EmptyAdapter added in v0.0.5

type EmptyAdapter struct {
}

EmptyAdapter empty adapter for extension to init enforcer

func (*EmptyAdapter) Delete added in v0.0.5

func (e *EmptyAdapter) Delete(key string) error

func (*EmptyAdapter) DeleteStr added in v0.0.5

func (e *EmptyAdapter) DeleteStr(key string) error

func (*EmptyAdapter) Get added in v0.0.5

func (e *EmptyAdapter) Get(key string, t ...reflect.Type) interface{}

func (*EmptyAdapter) GetStr added in v0.0.5

func (e *EmptyAdapter) GetStr(key string) string

func (*EmptyAdapter) GetStrTimeout added in v0.0.5

func (e *EmptyAdapter) GetStrTimeout(key string) int64

func (*EmptyAdapter) GetTimeout added in v0.0.5

func (e *EmptyAdapter) GetTimeout(key string) int64

func (*EmptyAdapter) Set added in v0.0.5

func (e *EmptyAdapter) Set(key string, value interface{}, timeout int64) error

func (*EmptyAdapter) SetSerializer added in v0.0.8

func (e *EmptyAdapter) SetSerializer(serializer Serializer)

func (*EmptyAdapter) SetStr added in v0.0.5

func (e *EmptyAdapter) SetStr(key string, value string, timeout int64) error

func (*EmptyAdapter) Update added in v0.0.5

func (e *EmptyAdapter) Update(key string, value interface{}) error

func (*EmptyAdapter) UpdateStr added in v0.0.5

func (e *EmptyAdapter) UpdateStr(key string, value string) error

func (*EmptyAdapter) UpdateStrTimeout added in v0.0.5

func (e *EmptyAdapter) UpdateStrTimeout(key string, timeout int64) error

func (*EmptyAdapter) UpdateTimeout added in v0.0.5

func (e *EmptyAdapter) UpdateTimeout(key string, timeout int64) error

type JsonAdapter added in v0.0.4

type JsonAdapter struct {
}

type JsonSerializer added in v0.0.7

type JsonSerializer struct {
}

func NewJsonSerializer added in v0.0.7

func NewJsonSerializer() *JsonSerializer

func (*JsonSerializer) Serialize added in v0.0.7

func (j *JsonSerializer) Serialize(data interface{}) ([]byte, error)

func (*JsonSerializer) UnSerialize added in v0.0.7

func (j *JsonSerializer) UnSerialize(data []byte, result interface{}) error

type Serializer added in v0.0.8

type Serializer interface {
	Serialize(data interface{}) ([]byte, error)
	UnSerialize([]byte, interface{}) error
}

type UpdatableWatcher added in v0.1.6

type UpdatableWatcher interface {
	UpdateForSetStr(key string, value string, timeout int64) error
	UpdateForUpdateStr(key string, value string) error
	UpdateForSet(key string, value interface{}, timeout int64) error
	UpdateForUpdate(key string, value interface{}) error
	UpdateForDelete(key string) error
	UpdateForUpdateTimeout(key string, timeout int64) error
}

UpdatableWatcher called when data updated

type Watcher

type Watcher interface {
	// Login called after login
	Login(loginType string, id interface{}, tokenValue string, loginModel *model.Login)
	// Logout called after logout
	Logout(loginType string, id interface{}, tokenValue string)
	// Kickout called when being kicked out of the server
	Kickout(loginType string, id interface{}, tokenValue string)
	// Replace called when Someone else has taken over your account
	Replace(loginType string, id interface{}, tokenValue string)
	// Ban called when account banned
	Ban(loginType string, id interface{}, service string, level int, time int64)
	// UnBan called when account has been unbanned.
	UnBan(loginType string, id interface{}, service string)
	// RefreshToken called when renew token timeout
	RefreshToken(tokenValue string, id interface{}, timeout int64)
	// OpenSafe called when open second auth
	OpenSafe(loginType string, token string, service string, time int64)
	// CloseSafe called when close second auth
	CloseSafe(loginType string, token string, service string)
}

Watcher event watcher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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