func ROPCRefreshTokenExists(refreshToken string, invalidateIfFound bool) bool {
	conn := NewConn()
	defer CloseConn(conn)
	var token internalROPCToken
	items, err := redis.ByteSlices(conn.Do("HGETALL", ropcTokensSet))
	if err != nil {
		log.Println(err)
	}
	for i := 1; i < len(items); i += 2 {
		err := json.Unmarshal(items[i], &token)
		if err != nil {
			log.Println(err)
			break
		}
		if refreshToken == token.Token.RefreshToken {
			if invalidateIfFound {
				invalidateROPCToken(token.Token.AccessToken)
			}
			return true
		}
	}
	return false
}
ROPCRefreshTokenExists checks if the refresh token exists in the Redis cache
and returns the appropriate boolean value.
Params:
refreshToken: the token to look for in the cache
invalidateIfFound: if true, the token is invalidated if found
package cache
import (
	"encoding/json"
	"fmt"
	"log"
	"time"
	"github.com/gomodule/redigo/redis"
)
const (
	ropcTokensSet = "OA2B_ROPC_Tokens"
	ROPCFlowID = "PASSCRED"
)
type ROPCToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
}
type ropcTokenMeta struct {
	CreationTime time.Time `json:"creation_time"`
	Nonce        string    `json:"nonce"`
}
type internalROPCToken struct {
	Token ROPCToken     `json:"token"`
	Meta  ropcTokenMeta `json:"meta"`
}
func NewROPCToken(refreshToken string) (*ROPCToken, error) {
	conn := NewConn()
	defer CloseConn(conn)
	var token *ROPCToken
	var meta *ropcTokenMeta
	var err error
	reply := 1
	for reply == 1 {
		token, meta = generateROPCToken()
		if len(refreshToken) == 72 {
			token.RefreshToken = refreshToken
		}
		reply, err = redis.Int(conn.Do("HEXISTS", ropcTokensSet, token.AccessToken))
		if err != nil {
			log.Println(err)
			return nil, err
		}
	}
	jsonBytes, err := json.Marshal(internalROPCToken{Token: *token, Meta: *meta})
	if err != nil {
		panic(err)
	}
	_, err = conn.Do("HSET", ropcTokensSet, token.AccessToken, string(jsonBytes))
	if err != nil {
		return nil, err
	}
	return token, nil
}
func NewROPCRefreshToken(refreshToken string) (*ROPCToken, error) {
	token, err := NewROPCToken(refreshToken)
	if err != nil {
		return nil, err
	}
	return token, nil
}