Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: wecom id cache (#13161)
p0ny2fda260fca9e
diff --git a/backend/plugin/webhook/wecom/app.go b/backend/plugin/webhook/wecom/app.goindex 1c787c0ba4..d931b2f76a 100644--- a/backend/plugin/webhook/wecom/app.go+++ b/backend/plugin/webhook/wecom/app.go@@ -121,6 +121,10 @@ func (p *provider) refreshToken(ctx context.Context) error {}func (p *provider) getUserIDByEmail(ctx context.Context, email string) (string, error) {+ if id, ok := userIDCache.Get(email); ok {+ return id, nil+ }+url, err := url.Parse("https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email")if err != nil {return "", errors.Wrapf(err, "failed to parse url")@@ -149,6 +153,8 @@ func (p *provider) getUserIDByEmail(ctx context.Context, email string) (string,return "", errors.Wrapf(err, "failed to unmarshal payload for get user id by email")}+ userIDCache.Add(email, payload.UserID)+return payload.UserID, nil}@@ -264,6 +270,14 @@ var tokenCache = func() *lru.Cache[cacheKey, *tokenValue] {var tokenCacheLock sync.Mutex+var userIDCache = func() *lru.Cache[string, string] {+ cache, err := lru.New[string, string](5000)+ if err != nil {+ panic(err)+ }+ return cache+}()+func getTokenCached(ctx context.Context, c *http.Client, corpID, secret string) (string, error) {tokenCacheLock.Lock()defer tokenCacheLock.Unlock()