mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
add redis recorder expiry time
This commit is contained in:
parent
465f5d5bf1
commit
717a8d1d24
@ -33,13 +33,13 @@ func (r *Redis) SyncOnlineIp(Ips []dispatcher.UserIpList) ([]dispatcher.UserIpLi
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("add user failed: %s", err)
|
||||
}
|
||||
r.client.Expire(ctx, "UserList", 2*time.Minute)
|
||||
r.client.Expire(ctx, "UserList", time.Second*time.Duration(r.Expiry))
|
||||
for _, ip := range Ips[i].IpList {
|
||||
err := r.client.SAdd(ctx, strconv.Itoa(Ips[i].Uid), ip).Err()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("add ip failed: %s", err)
|
||||
}
|
||||
r.client.Expire(ctx, strconv.Itoa(Ips[i].Uid), 2*time.Minute)
|
||||
r.client.Expire(ctx, strconv.Itoa(Ips[i].Uid), time.Second*time.Duration(r.Expiry))
|
||||
}
|
||||
}
|
||||
c := r.client.SMembers(ctx, "UserList")
|
||||
|
@ -29,6 +29,7 @@ type RedisConfig struct {
|
||||
Address string `yaml:"Address"`
|
||||
Password string `yaml:"Password"`
|
||||
Db int `yaml:"Db"`
|
||||
Expiry int `json:"Expiry"`
|
||||
}
|
||||
|
||||
type IpReportConfig struct {
|
||||
|
@ -51,6 +51,7 @@ Nodes:
|
||||
Address: "127.0.0.1:6379" # Redis address
|
||||
Password: "" # Redis password
|
||||
DB: 0 # Redis DB
|
||||
Expiry: 60 # redis expiry time, sec.
|
||||
Periodic: 60 # Report interval, sec.
|
||||
EnableIpSync: false # Enable online ip sync
|
||||
EnableDynamicSpeedLimit: false # Enable dynamic speed limit
|
||||
|
Loading…
Reference in New Issue
Block a user