split sign and reset

This commit is contained in:
2025-01-30 11:33:16 -06:00
parent 597532bf26
commit 6dd84e4ca3
8 changed files with 441 additions and 47 deletions

38
memCache/forgot_nkode.go Normal file
View File

@@ -0,0 +1,38 @@
package memCache
import (
"git.infra.nkode.tech/dkelly/nkode-core/entities"
"github.com/patrickmn/go-cache"
"time"
)
const (
forgotExpiration = 5 * time.Minute
forgotCleanupInterval = 10 * time.Minute
)
type ForgotNKodeCache struct {
innerCache *cache.Cache
}
func NewForgotNKodeCache() ForgotNKodeCache {
forgotCache := cache.New(forgotExpiration, forgotCleanupInterval)
return ForgotNKodeCache{forgotCache}
}
func (f *ForgotNKodeCache) Set(userEmail entities.UserEmail, customerId entities.CustomerId) {
f.innerCache.Set(key(userEmail, customerId), true, forgotExpiration)
}
func (f *ForgotNKodeCache) Get(userEmail entities.UserEmail, customerId entities.CustomerId) bool {
_, found := f.innerCache.Get(key(userEmail, customerId))
return found
}
func (f *ForgotNKodeCache) Delete(userEmail entities.UserEmail, customerId entities.CustomerId) {
f.innerCache.Delete(key(userEmail, customerId))
}
func key(email entities.UserEmail, id entities.CustomerId) string {
return string(email) + entities.CustomerIdToString(id)
}