package auth import ( "time" "github.com/go-redis/redis" ) 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 int64) error { return rss.client.Set(key, value, time.Duration(timeout) * time.Second).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 }