Exemple #1
0
/* DATABASE */
func GetNextID() int {
	db := redis.NewRedisClient()
	id, err := strconv.Atoi(db.Get("id_counter").Val())
	if err != nil {
		id = 0
	}
	id += 1
	db.Set("id_counter", strconv.Itoa(id), 0)
	return id
}
Exemple #2
0
// FetchUser tries to fetch an user based on an ID
func FetchUser(email string) (*User, error) {
	db := redis.NewRedisClient()
	u := User{}
	err := db.GetStruct(email, &u)
	return &u, err
}
Exemple #3
0
// SaveUser stores user in database
func (u *User) SaveUser() error {
	db := redis.NewRedisClient()
	u.ID = GetNextID()
	return db.StoreStruct(u.Email, u)
}