storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init 初始化

func SetRedisPoolConfig

func SetRedisPoolConfig(c *PoolTimeConfig)

SetRedisPoolConfig 设置redis连接池的配置

Types

type IdempotenceStorage

type IdempotenceStorage int8

IdempotenceStorage IdempotenceStorage

const (
	// Mongo Mongo
	Mongo IdempotenceStorage = iota
	// Redis Redis
	Redis
)

type PoolTimeConfig

type PoolTimeConfig struct {
	// 连接池中拥有的最小连接数
	InitialCap int
	// 最大并发存活连接数
	MaxCap int
	// 最大空闲连接
	MaxIdle int
	// 连接最大空闲时间,超过该事件则将失效
	IdleTimeout time.Duration
}

PoolTimeConfig 连接池时间配置

type RedisStorage

type RedisStorage struct {
}

RedisStorage RedisStorage

func NewRedisStorage

func NewRedisStorage() *RedisStorage

NewRedisStorage NewRedisStorage

func (*RedisStorage) CheckAndSetStatus

func (idempotence *RedisStorage) CheckAndSetStatus(id string, status []string, newStatus string, t int) bool

CheckAndSetStatus 检测并且设置

func (*RedisStorage) CheckStatus

func (idempotence *RedisStorage) CheckStatus(id string, status []string) bool

CheckStatus 检测状态

func (*RedisStorage) Delete

func (idempotence *RedisStorage) Delete(idempotenceID id.IdempotenceID) bool

Delete 删除

func (*RedisStorage) SaveIfAbsent

func (idempotence *RedisStorage) SaveIfAbsent(idempotenceID id.IdempotenceID) bool

SaveIfAbsent 如果没有则保存

func (*RedisStorage) SaveStatusIfAbsent

func (idempotence *RedisStorage) SaveStatusIfAbsent(id, status string, t time.Duration) bool

SaveStatusIfAbsent 不存在则设置状态

type Storage

type Storage interface {
	SaveIfAbsent(idempotenceID id.IdempotenceID) bool
	Delete(idempotenceID id.IdempotenceID) bool
	SaveStatusIfAbsent(id, status string, t time.Duration) bool
	CheckStatus(id string, status []string) bool
	CheckAndSetStatus(id string, status []string, newStatus string, t int) bool
}

Storage 存储接口

func NewStorage

func NewStorage(s IdempotenceStorage) Storage

NewStorage NewStorage

Jump to

Keyboard shortcuts

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