Пример #1
0
func addRemoveGroups(client redis.Client, articleID int, toAdd, toRemove []string) {

	article := "article:" + strconv.Itoa(articleID)

	for _, group := range toAdd {
		if _, err := client.Sadd("group:"+group, []byte(article)); err != nil {
			log.Fatal("Sadd エラーだよ", err.Error())
		}
	}

	for _, group := range toRemove {
		if _, err := client.Srem("group:"+group, []byte(article)); err != nil {
			log.Fatal("Srem エラーだよ", err.Error())
		}
	}
}