5 type intentStruct struct {
10 type intentMapStruct struct {
12 m map[string]*intentStruct
15 var intentMap = &intentMapStruct{
16 m: map[string]*intentStruct{},
19 // Register a channel to be notified when the specified keys are notified.
21 // Cache checks should be done after registering intent, since it's possible to
22 // register Intent while a Notify is running, and the Notify is done after
24 func (m *intentMapStruct) Intent(ch chan Cacheable, keys ...cacheKey) bool {
25 key := cachePath(keys...)
36 s.chs = append(s.chs, ch)
42 // Notify all channels that are listening for the specified keys.
44 // Should be called after setting the cache.
45 func (m *intentMapStruct) Notify(v Cacheable, keys ...cacheKey) {
46 key := cachePath(keys...)
58 for _, ch := range s.chs {
59 go func(c chan Cacheable) { c <- v }(ch)