# README
Idempotent
api idempotent tool based on redis lua script.
Usage
go get -u github.com/go-cinch/common/idempotent
import (
"context"
"fmt"
"github.com/go-cinch/common/idempotent"
"github.com/redis/go-redis/v9"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 0,
})
i := idempotent.New(
idempotent.WithRedis(client),
)
token := i.Token(context.Background())
fmt.Println(i.Check(context.Background(), token))
// true
// second check will fail
fmt.Println(i.Check(context.Background(), token))
// false
}
Options
WithRedis
- redis client, default 127.0.0.1:6379WithPrefix
- cache key prefix, default idempotentWithExpire
- key expire time, default 60 minute
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author