25 lines
399 B
Go
25 lines
399 B
Go
|
package context
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/patrickmn/go-cache"
|
||
|
)
|
||
|
|
||
|
func (c *CacheContext) GetUser(username string) bool {
|
||
|
_, found := c.UsernameCache.Get(username)
|
||
|
return found
|
||
|
}
|
||
|
|
||
|
func (c *CacheContext) SetUser(username string) {
|
||
|
c.UsernameCache.Set(
|
||
|
username,
|
||
|
true,
|
||
|
cache.DefaultExpiration,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func MakeUsernameCache() cache.Cache {
|
||
|
return *cache.New(24*time.Hour, 12*time.Hour)
|
||
|
}
|