lxlimit

package module
v0.0.0-...-7635ac6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: OSL-3.0 Imports: 8 Imported by: 0

README

api限流

202401231510

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLimit

func CheckLimit(cfg MFuncConfig) (gameid, tp string)

CheckLimit 检查是否超 出限制

func InitDefault

func InitDefault(cfg LimitConfig) (err error)

InitDefault 初始化

Types

type LXredis

type LXredis struct {
	Name   string `json:"name"`
	Val    string `json:"val"`
	Db     string `json:"db"`
	Prefix string `json:"prefix"`
}

func (*LXredis) EXPIRE

func (con *LXredis) EXPIRE(times int) (err error)

EXPIRE 设置过期时间

func (*LXredis) GET

func (con *LXredis) GET() (gstr string, err error)

GET 获取redis

func (*LXredis) INCR

func (con *LXredis) INCR() (nums int64, err error)

INCR 自增

func (*LXredis) IsExist

func (con *LXredis) IsExist() (isexit bool, err error)

IsExist 判断key是否存在

func (*LXredis) TTL

func (con *LXredis) TTL() (ttl int, err error)

TTL 查看过期时间

type LimitConfig

type LimitConfig struct {
	Redis MapRedisConfig `json:"redis"`
	Func  MFuncConfig    `json:"func"`
}

type LimitVar

type LimitVar struct {
	RedisConfig MapRedisConfig
	RedisPool   *redigo.Pool
	FuncConfig  MFuncConfig
}
var LXLIMITCL LimitVar

type MFuncConfig

type MFuncConfig struct {
	FunName    string            `json:"fun_name"`
	Open       bool              `json:"open"`
	Ip         MFuncItem         `json:"ip"`
	Kernel     MFuncItem         `json:"kernel"`
	BodyBy     []byte            `json:"bodyBy"`
	Url        string            `json:"url"`
	Params     map[string]string `json:"params"`
	DelGameIDS []string          `json:"delGameIDS"` // 删除某个游戏
	Member     MFuncItem         `json:"member"`
}

type MFuncItem

type MFuncItem struct {
	Name  string `json:"name"`
	Times int    `json:"times"` // 每几秒
	Nums  int    `json:"nums"`  // 限制多少次
}

type MapRedisConfig

type MapRedisConfig struct {
	Host   string `json:"host"`
	Port   string `json:"port"`
	Pwd    string `json:"pwd"`
	Db     string `json:"Db"`
	Prefix string `json:"prefix"`
}

Jump to

Keyboard shortcuts

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