diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2018-12-27 07:57:48 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2018-12-27 07:57:48 -0500 |
| commit | b953a2c81fa8a66a58a9c0ec185da48ce853e8d9 (patch) | |
| tree | 86fd378f3b38a3ea9343160d61472115ec50a179 /store.go | |
| parent | ed4f6fa1a785e14f39bda9715e3d081fb426ff36 (diff) | |
| download | id-b953a2c81fa8a66a58a9c0ec185da48ce853e8d9.tar.gz | |
WIP: not working
Diffstat (limited to 'store.go')
| -rw-r--r-- | store.go | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -9,14 +9,20 @@ import ( type Session struct { Id string - UserId string + UserId int64 } -type SessionStore interface { - Get(id string) (*Session, bool) +type User struct { + Id int64 + UserName string } -type PgSessionStore struct { +type Store interface { + GetSession(id string) (*Session, bool) + GetUser(id int64) (*User, bool) +} + +type PgStore struct { *sql.DB cache map[string]*Session } @@ -31,5 +37,10 @@ func NewPgStore() *PgSessionStore { func (store *PgSessionStore) Get(id string) (*Session, bool) { s, ok := store.cache[id] + if !ok { + row := store.QueryRow("SELECT id, user_id FROM session WHERE id = ?", id) + var s Session + row.Scan(&s. + } return s, ok } |
