Beispiel #1
0
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)
}
Beispiel #2
0
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
}
Beispiel #3
0
func CloseRDB(c *redis.Client) {
	c.Quit()
}
Beispiel #4
0
func PullRDB(country_name string, c *redis.Client) []string {
	reply, _ := c.Smembers(country_name)
	str := reply.StringArray()
	return str
}
Beispiel #5
0
func GetCountries(c *redis.Client) []string {
	reply, _ := c.Smembers("countries")
	str := reply.StringArray()
	return str
}