goshorly/db/AddLinks.go

24 lines
383 B
Go
Raw Normal View History

package db
import (
"strconv"
)
func StatsIncreaseTotalLinks() (int, error) {
2022-01-13 19:06:30 +00:00
val, err := Client.Get(ctx, "total-links").Result()
if err != nil {
2022-01-13 19:06:30 +00:00
err := Client.Set(ctx, "total-links", "0", 0).Err()
if err != nil {
return 0, err
}
}
i, _ := strconv.Atoi(val)
i++
2022-01-13 19:06:30 +00:00
err = Client.Set(ctx, "total-links", i, 0).Err()
if err != nil {
return 0, err
}
return i, nil
}