Move utils into shared folder
This commit is contained in:
parent
500bf48295
commit
c25f27e82e
22 changed files with 111 additions and 137 deletions
|
@ -6,7 +6,8 @@ import (
|
|||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/rs/zerolog/log"
|
||||
"git.mstar.dev/mstar/linstrom/util"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/shared"
|
||||
)
|
||||
|
||||
// various prefixes for accessing items in the cache (since it's a simple key-value store)
|
||||
|
@ -26,7 +27,7 @@ var errCacheNotFound = errors.New("not found in cache")
|
|||
// err contains an error describing why an account's id couldn't be found
|
||||
// The most common one should be errCacheNotFound
|
||||
func (s *Storage) cacheHandleToAccUid(handle string) (accId *string, err error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
defer shared.Untrace(shared.Trace(&log.Logger))
|
||||
// Where to put the data (in case it's found)
|
||||
var target string
|
||||
found, err := s.cache.Get(cacheUserHandleToIdPrefix+strings.TrimLeft(handle, "@"), &target)
|
||||
|
@ -48,7 +49,7 @@ func (s *Storage) cacheHandleToAccUid(handle string) (accId *string, err error)
|
|||
// err contains an error describing why an account's id couldn't be found
|
||||
// The most common one should be errCacheNotFound
|
||||
func (s *Storage) cacheLocalUsernameToAccUid(username string) (accId *string, err error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
defer shared.Untrace(shared.Trace(&log.Logger))
|
||||
// Where to put the data (in case it's found)
|
||||
var target string
|
||||
found, err := s.cache.Get(cacheLocalUsernameToIdPrefix+username, &target)
|
||||
|
@ -66,7 +67,7 @@ func (s *Storage) cacheLocalUsernameToAccUid(username string) (accId *string, er
|
|||
}
|
||||
|
||||
func (s *Storage) cachePkeyIdToAccId(pkeyId []byte) (accId *string, err error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
defer shared.Untrace(shared.Trace(&log.Logger))
|
||||
// Where to put the data (in case it's found)
|
||||
var target string
|
||||
found, err := s.cache.Get(cachePasskeyIdToAccIdPrefix+string(pkeyId), &target)
|
||||
|
@ -88,7 +89,7 @@ func (s *Storage) cachePkeyIdToAccId(pkeyId []byte) (accId *string, err error) {
|
|||
// err contains an error describing why an account couldn't be found
|
||||
// The most common one should be errCacheNotFound
|
||||
func (s *Storage) cacheAccIdToData(id string) (acc *Account, err error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
defer shared.Untrace(shared.Trace(&log.Logger))
|
||||
var target Account
|
||||
found, err := s.cache.Get(cacheUserIdToAccPrefix+id, &target)
|
||||
if !found {
|
||||
|
@ -106,7 +107,7 @@ func (s *Storage) cacheAccIdToData(id string) (acc *Account, err error) {
|
|||
// err contains an error describing why a note couldn't be found
|
||||
// The most common one should be errCacheNotFound
|
||||
func (s *Storage) cacheNoteIdToData(id string) (note *Note, err error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
defer shared.Untrace(shared.Trace(&log.Logger))
|
||||
target := Note{}
|
||||
found, err := s.cache.Get(cacheNoteIdToNotePrefix+id, &target)
|
||||
if !found {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue