MCPcopy Index your code
hub / github.com/coder/coder / cachedSubscriptions

Method cachedSubscriptions

coderd/webpush/webpush.go:314–332  ·  view source on GitHub ↗
(userID uuid.UUID)

Source from the content-addressed store, hash-verified

312}
313
314func (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
334func (n *Webpusher) subscriptionGeneration(userID uuid.UUID) uint64 {
335 n.cacheMu.RLock()

Callers 1

subscriptionsForUserMethod · 0.95

Calls 3

CloneMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected