connect to redis session

This commit is contained in:
Gregory Wells
2026-06-07 20:07:20 -04:00
parent e1862ca8eb
commit 1e87b8239b
+24 -2
View File
@@ -1,15 +1,37 @@
package session package session
import ( import (
"context"
"astraltech.xyz/accountmanager/src/logging" "astraltech.xyz/accountmanager/src/logging"
"github.com/redis/go-redis/v9"
) )
type RedisStore struct { type RedisStore struct {
client *redis.Client
} }
func NewRedisStore() *RedisStore { func NewRedisStore() *RedisStore {
logging.Debug("Creating new in redis session store") logging.Debug("Creating new redis session store")
store := &RedisStore{}
redis_server := "localhost:6379"
// redis values will need to be loaded from the config file
rdb := redis.NewClient(&redis.Options{
Addr: redis_server,
Password: "",
DB: 0,
})
if err := rdb.Ping(context.Background()).Err(); err != nil {
logging.Errorf("Failed to connect to redis server %s", redis_server)
} else {
logging.Infof("Successfully connected to redis server %s", redis_server)
}
store := &RedisStore{
client: rdb,
}
return store return store
} }