Exemplo n.º 1
0
// rdConnect: connect to the given Redis URL.  Returns the
// connection id, if successful, an error otherwise.
func rdConnect() (string, error) {
	conn, err := redis.DialURL(rdUrl)
	if err != nil {
		err = fmt.Errorf("Couldn't connect to cache at %q: %v", rdUrl, err)
		return "", err
	}
	rdc = conn
	return rdUrl, nil
}
Exemplo n.º 2
0
func ClearCache() error {
	url := os.Getenv("REDISTOGO_URL")
	if url == "" {
		url = "redis://localhost:6379/"
	}
	conn, err := redis.DialURL(url)
	if err != nil {
		return err
	}
	_, err = conn.Do("FLUSHALL")
	if err != nil {
		return err
	}
	conn.Close()
	return nil
}