MCPcopy
hub / github.com/usememos/memos / GetUser

Method GetUser

store/user.go:146–167  ·  view source on GitHub ↗
(ctx context.Context, find *FindUser)

Source from the content-addressed store, hash-verified

144}
145
146func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
147 if find.ID != nil {
148 if cache, ok := s.userCache.Get(ctx, userCacheKey(*find.ID)); ok {
149 user, ok := cache.(*User)
150 if ok {
151 return user, nil
152 }
153 }
154 }
155
156 list, err := s.ListUsers(ctx, find)
157 if err != nil {
158 return nil, err
159 }
160 if len(list) == 0 {
161 return nil, nil
162 }
163
164 user := list[0]
165 s.userCache.Set(ctx, userCacheKey(user.ID), user)
166 return user, nil
167}
168
169func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error) {
170 result, err := s.driver.DeleteUser(ctx, delete)

Callers 1

GetUserByPATHashMethod · 0.95

Calls 4

ListUsersMethod · 0.95
userCacheKeyFunction · 0.85
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected