func PushRDB(c *redis.Client, country string, sentiment_val float64, pos_words, neg_words []string) { cs := CountrySentiment{Timestamp: time.Now(), Values: sentiment_val, Pos: pos_words, Neg: neg_words} b, err := json.Marshal(cs) if err != nil { log.Fatal(err) } c.Sadd(country, b) }
func redisGet(redisClient *redis.Client, key string) []byte { var result []byte err := retry(50, 100*time.Millisecond, func() error { var err error result, err = redisClient.Get(key) if err != nil { fmt.Println("redis retry...") } return err }) if err != nil { panic(err) } return result }
func CloseRDB(c *redis.Client) { c.Quit() }
func PullRDB(country_name string, c *redis.Client) []string { reply, _ := c.Smembers(country_name) str := reply.StringArray() return str }
func GetCountries(c *redis.Client) []string { reply, _ := c.Smembers("countries") str := reply.StringArray() return str }