(userID uuid.UUID)
| 312 | } |
| 313 | |
| 314 | func (n *Webpusher) cachedSubscriptions(userID uuid.UUID) ([]database.WebpushSubscription, bool) { |
| 315 | n.cacheMu.RLock() |
| 316 | entry, ok := n.subscriptionCache[userID] |
| 317 | n.cacheMu.RUnlock() |
| 318 | if !ok { |
| 319 | return nil, false |
| 320 | } |
| 321 | if n.clock.Now().Before(entry.expiresAt) { |
| 322 | return slices.Clone(entry.subscriptions), true |
| 323 | } |
| 324 | |
| 325 | n.cacheMu.Lock() |
| 326 | if current, ok := n.subscriptionCache[userID]; ok && !n.clock.Now().Before(current.expiresAt) { |
| 327 | delete(n.subscriptionCache, userID) |
| 328 | } |
| 329 | n.cacheMu.Unlock() |
| 330 | |
| 331 | return nil, false |
| 332 | } |
| 333 | |
| 334 | func (n *Webpusher) subscriptionGeneration(userID uuid.UUID) uint64 { |
| 335 | n.cacheMu.RLock() |
no test coverage detected