2022-01-08 16:21:53 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func StatsIncreaseTotalLinks() (int, error) {
|
2022-01-25 18:14:09 +00:00
|
|
|
val, err := Client_redis().Get(ctx, "total-links").Result()
|
2022-01-08 16:21:53 +00:00
|
|
|
|
|
|
|
if err != nil {
|
2022-01-25 18:14:09 +00:00
|
|
|
err := Client_redis().Set(ctx, "total-links", "0", 0).Err()
|
2022-01-08 16:21:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i, _ := strconv.Atoi(val)
|
|
|
|
i++
|
2022-01-25 18:14:09 +00:00
|
|
|
err = Client_redis().Set(ctx, "total-links", i, 0).Err()
|
2022-01-08 16:21:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return i, nil
|
|
|
|
}
|