package auth import ( "github.com/go-redis/redis" "time" ) type RedisSessionStore struct{ client *redis.Client } func NewRedisSessionStore(address string, password string) *RedisSessionStore { session := &RedisSessionStore{} session.client = redis.NewClient(&redis.Options{ Addr: address, Password: password, }) if err := session.client.Ping().Err(); err != nil { panic(err) } return session } func (rss *RedisSessionStore) StoreJwtToken(key string, value string, timeout time.Duration) error { return rss.client.Set(key, value, timeout).Err() } func (rss *RedisSessionStore) IsExistsJwtToken(key string) bool { return rss.client.Exists(key).Val() == 1 } func (rss *RedisSessionStore) DeleteJwtToken(key string) bool { return rss.client.Del(key).Val() == 1 }