(WIP) Refresh & Access

This commit is contained in:
2021-01-17 23:56:56 -05:00
parent cd97b6262f
commit 377903f7a1
14 changed files with 366 additions and 136 deletions

View File

@@ -4,8 +4,11 @@ import (
"sync"
)
// Used to maintain a cache of user specific jwt secrets
// This will prevent DB lookups on every request
type SessionManager struct {
Mutex sync.Mutex
mutex sync.Mutex
values map[string]string
}
func NewMgr() *SessionManager {
@@ -13,13 +16,23 @@ func NewMgr() *SessionManager {
}
func (sm *SessionManager) Set(key, value string) {
sm.mutex.Lock()
sm.values[key] = value
sm.mutex.Unlock()
}
func (sm *SessionManager) Get(key string) string {
return ""
sm.mutex.Lock()
defer sm.mutex.Unlock()
return sm.values[key]
}
func (sm *SessionManager) Delete(key string) {
sm.mutex.Lock()
defer sm.mutex.Unlock()
_, exists := sm.values[key]
if !exists {
return
}
delete(sm.values, key)
}