25 lines
538 B
Go
25 lines
538 B
Go
package db
|
|
|
|
import (
|
|
"github.com/mediocregopher/radix/v3"
|
|
)
|
|
|
|
func GetFromKey(key string, target interface{}) error {
|
|
return DB.Redis.Do(radix.FlatCmd(target, "GET", key))
|
|
}
|
|
|
|
func SetKeyVal(key string, val interface{}) error {
|
|
return DB.Redis.Do(radix.FlatCmd(nil, "SET", key, val))
|
|
}
|
|
|
|
func ExpireKey(key string, seconds int) error {
|
|
return DB.Redis.Do(radix.FlatCmd(nil, "EXPIRE", key, seconds))
|
|
}
|
|
|
|
func Exists(key string) (bool, error) {
|
|
var exists bool
|
|
err := DB.Redis.Do(radix.Cmd(&exists, "EXISTS", key))
|
|
|
|
return exists, err
|
|
}
|