Skip to content

Commit

Permalink
invalidate user cache when adding new user
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Dec 19, 2024
1 parent 05b9147 commit 9649822
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/walletextension/storage/storage_with_cache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package storage

import (
"fmt"

"github.com/ethereum/go-ethereum/log"
"github.com/ten-protocol/go-ten/go/common/viewingkey"
"github.com/ten-protocol/go-ten/tools/walletextension/cache"
Expand Down Expand Up @@ -29,7 +31,14 @@ func NewUserStorageWithCache(storage UserStorage, logger log.Logger) (*UserStora

// AddUser adds a new user and invalidates the cache for the userID
func (s *UserStorageWithCache) AddUser(userID []byte, privateKey []byte) error {
return s.storage.AddUser(userID, privateKey)
fmt.Printf("Adding user %s to CosmosDB\n", userID)
err := s.storage.AddUser(userID, privateKey)
if err != nil {
return err
}
fmt.Printf("User %s added to CosmosDB successfully\n", userID)
s.cache.Remove(userID)
return nil
}

// DeleteUser deletes a user and invalidates the cache for the userID
Expand Down

0 comments on commit 9649822

Please sign in to comment.