notifyWatchers sends notification to all watchers of given key. If delay is enabled, it accumulates them for later sending.
(key string)
| 1168 | // notifyWatchers sends notification to all watchers of given key. If delay is |
| 1169 | // enabled, it accumulates them for later sending. |
| 1170 | func (m *KV) notifyWatchers(key string) { |
| 1171 | if m.cfg.NotifyInterval <= 0 { |
| 1172 | m.notifyWatchersSync(key) |
| 1173 | return |
| 1174 | } |
| 1175 | |
| 1176 | m.notifMu.Lock() |
| 1177 | defer m.notifMu.Unlock() |
| 1178 | m.keyNotifications[key] = struct{}{} |
| 1179 | } |
| 1180 | |
| 1181 | // monitorKeyNotifications sends accumulated notifications to all watchers of |
| 1182 | // respective keys when the given channel ticks. |