Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
eddycjy committed Jun 17, 2018
1 parent efdce61 commit 5c96763
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/gredis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,26 @@ func Setup() error {
return nil
}

func Set(key string, data interface{}, time int) (bool, error) {
func Set(key string, data interface{}, time int) error {
conn := RedisConn.Get()
defer conn.Close()

value, err := json.Marshal(data)
if err != nil {
return false, err
return err
}

reply, err := redis.Bool(conn.Do("SET", key, value))
conn.Do("EXPIRE", key, time)
_, err = conn.Do("SET", key, value)
if err != nil {
return err
}

return reply, err
_, err = conn.Do("EXPIRE", key, time)
if err != nil {
return err
}

return nil
}

func Exists(key string) bool {
Expand Down

0 comments on commit 5c96763

Please sign in to comment.