Skip to content

Commit

Permalink
Merge pull request #3028 from target/lower-slack-cache-time
Browse files Browse the repository at this point in the history
slack: lower slack cache time
  • Loading branch information
mastercactapus authored May 22, 2023
2 parents 979aa39 + 6888104 commit 58a2c29
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 11 additions & 9 deletions notification/slack/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func NewChannelSender(ctx context.Context, cfg Config) (*ChannelSender, error) {

listCache: newTTLCache[string, []Channel](250, time.Minute),
chanCache: newTTLCache[string, *Channel](1000, 15*time.Minute),
ugCache: newTTLCache[string, []slack.UserGroup](1000, 15*time.Minute),
ugCache: newTTLCache[string, []slack.UserGroup](1000, time.Minute),

teamInfoCache: newTTLCache[string, *slack.TeamInfo](1, 24*time.Hour),
userInfoCache: newTTLCache[string, *slack.User](1000, 24*time.Hour),
ugInfoCache: newTTLCache[string, UserGroup](1000, 24*time.Hour),
teamInfoCache: newTTLCache[string, *slack.TeamInfo](1, 15*time.Minute),
userInfoCache: newTTLCache[string, *slack.User](1000, 15*time.Minute),
ugInfoCache: newTTLCache[string, UserGroup](1000, 15*time.Minute),
}, nil
}

Expand Down Expand Up @@ -259,12 +259,14 @@ func (s *ChannelSender) loadChannels(ctx context.Context) ([]Channel, error) {

cursor = nextCursor

for _, ch := range respChan {
channels = append(channels, Channel{
ID: ch.ID,
Name: "#" + ch.Name,
for _, rCh := range respChan {
ch := Channel{
ID: rCh.ID,
Name: "#" + rCh.Name,
TeamID: teamID,
})
}
channels = append(channels, ch)
s.chanCache.Add(ch.ID, &ch)
}

return nil
Expand Down
6 changes: 4 additions & 2 deletions notification/slack/usergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ func (s *ChannelSender) ListUserGroups(ctx context.Context) ([]UserGroup, error)

res := make([]UserGroup, 0, len(groups))
for _, g := range groups {
res = append(res, UserGroup{
grp := UserGroup{
ID: g.ID,
Name: g.Name,
Handle: g.Handle,
})
}
res = append(res, grp)
s.ugInfoCache.Add(g.ID, grp)
}

return res, nil
Expand Down

0 comments on commit 58a2c29

Please sign in to comment.