调试完成redis流控
This commit is contained in:
@ -19,35 +19,15 @@ import (
|
||||
|
||||
func TestRedis_AllowN(t *testing.T) {
|
||||
_ = wrapRedis.Client.AddClient("test_rate_limit", &wrapRedisDefine.Options{
|
||||
Addr: "127.0.0.1:6379",
|
||||
Network: "TCP",
|
||||
ClientName: "",
|
||||
Protocol: 0,
|
||||
Username: "",
|
||||
Password: "123456",
|
||||
MaxRetries: 0,
|
||||
MinRetryBackoff: 0,
|
||||
MaxRetryBackoff: 0,
|
||||
DialTimeout: 0,
|
||||
ReadTimeout: 0,
|
||||
WriteTimeout: 0,
|
||||
ContextTimeoutEnabled: false,
|
||||
PoolFIFO: false,
|
||||
PoolSize: 0,
|
||||
PoolTimeout: 0,
|
||||
MinIdleConn: 0,
|
||||
MaxIdleConn: 0,
|
||||
MaxActiveConn: 0,
|
||||
ConnMaxIdleTime: 0,
|
||||
ConnMaxLifetime: 0,
|
||||
DisableIdentity: false,
|
||||
IdentitySuffix: "",
|
||||
Addr: "127.0.0.1:6379",
|
||||
Password: "123456",
|
||||
DB: 6,
|
||||
})
|
||||
RedisClient.SetRedisClient(wrapRedis.Client.GetRealClient("test_rate_limit"))
|
||||
for i := 0; i < 100; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
allow, err := RedisClient.AllowN(context.Background(), &define.LimitConfig{
|
||||
Key: "deman",
|
||||
Total: 600,
|
||||
Total: 60,
|
||||
Rate: 10,
|
||||
TimeInterval: 60,
|
||||
}, 8)
|
||||
|
Reference in New Issue
Block a user