Go Test
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type CharacterService struct {
|
||||
cache *Cache
|
||||
factory CharacterFactory
|
||||
}
|
||||
|
||||
func NewCharacterService(cache *Cache, factory CharacterFactory) *CharacterService {
|
||||
return &CharacterService{cache: cache, factory: factory}
|
||||
}
|
||||
|
||||
func (s *CharacterService) StaticInfo(alter string, equVersion string) (map[string]any, error) {
|
||||
key := "character:static:" + alter + ":" + equVersion
|
||||
return GetOrLoad(s.cache, key, 15*time.Minute, func() (map[string]any, error) {
|
||||
return s.factory.CharacterInfo(alter, equVersion)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user