goshorly/db/AddLinks.go

24 lines
407 B
Go
Raw Normal View History

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()
if err != nil {
2022-01-25 18:14:09 +00:00
err := Client_redis().Set(ctx, "total-links", "0", 0).Err()
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()
if err != nil {
return 0, err
}
return i, nil
}