idempotent

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorDoEmpty    = fmt.Errorf("do empty")
	ErrorCacheEmpty = fmt.Errorf("cache empty")
)

Functions

func DoIdempotent

func DoIdempotent(ctx context.Context, store *redis.Redis, key string, v any, seconds, expired int, fn func(ctx context.Context, v any) error) (bool, error)

Types

type Idempotent

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

func NewIdempotent

func NewIdempotent(store *redis.Redis, key string) *Idempotent

func (*Idempotent) Lock

func (i *Idempotent) Lock(ctx context.Context, seconds int) (bool, error)

Lock Lock

func (*Idempotent) SetCacheValue

func (i *Idempotent) SetCacheValue(ctx context.Context, v any, expired int) error

func (*Idempotent) TryGetCacheValue

func (i *Idempotent) TryGetCacheValue(ctx context.Context, v any) (cached bool, err error)

func (*Idempotent) Unlock

func (i *Idempotent) Unlock(ctx context.Context) error

Unlock Unlock

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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