@@ -56,18 +56,27 @@ func (c *Cache) GetProfile(ctx context.Context, id *commonpb.UserId) (*profilepb
5656}
5757
5858func (c * Cache ) SetDisplayName (ctx context.Context , id * commonpb.UserId , displayName string ) error {
59- c .cache .Remove (toCacheKey (id ))
60- return c .db .SetDisplayName (ctx , id , displayName )
59+ err := c .db .SetDisplayName (ctx , id , displayName )
60+ if err == nil {
61+ c .cache .Remove (toCacheKey (id ))
62+ }
63+ return err
6164}
6265
6366func (c * Cache ) LinkXAccount (ctx context.Context , userID * commonpb.UserId , xProfile * profilepb.XProfile , accessToken string ) error {
64- c .cache .Remove (toCacheKey (userID ))
65- return c .db .LinkXAccount (ctx , userID , xProfile , accessToken )
67+ err := c .db .LinkXAccount (ctx , userID , xProfile , accessToken )
68+ if err == nil {
69+ c .cache .Remove (toCacheKey (userID ))
70+ }
71+ return err
6672}
6773
6874func (c * Cache ) UnlinkXAccount (ctx context.Context , userID * commonpb.UserId , xUserID string ) error {
69- c .cache .Remove (toCacheKey (userID ))
70- return c .db .UnlinkXAccount (ctx , userID , xUserID )
75+ err := c .db .UnlinkXAccount (ctx , userID , xUserID )
76+ if err == nil {
77+ c .cache .Remove (toCacheKey (userID ))
78+ }
79+ return err
7180}
7281
7382func (c * Cache ) GetXProfile (ctx context.Context , userID * commonpb.UserId ) (* profilepb.XProfile , error ) {
0 commit comments