A Group is a cache namespace and associated data loaded spread over a group of 1 or more machines.
| 140 | // A Group is a cache namespace and associated data loaded spread over |
| 141 | // a group of 1 or more machines. |
| 142 | type Group struct { |
| 143 | name string |
| 144 | getter Getter |
| 145 | peersOnce sync.Once |
| 146 | peers PeerPicker |
| 147 | cacheBytes int64 // limit for sum of mainCache and hotCache size |
| 148 | |
| 149 | // mainCache is a cache of the keys for which this process |
| 150 | // (amongst its peers) is authoritative. That is, this cache |
| 151 | // contains keys which consistent hash on to this process's |
| 152 | // peer number. |
| 153 | mainCache cache |
| 154 | |
| 155 | // hotCache contains keys/values for which this peer is not |
| 156 | // authoritative (otherwise they would be in mainCache), but |
| 157 | // are popular enough to warrant mirroring in this process to |
| 158 | // avoid going over the network to fetch from a peer. Having |
| 159 | // a hotCache avoids network hotspotting, where a peer's |
| 160 | // network card could become the bottleneck on a popular key. |
| 161 | // This cache is used sparingly to maximize the total number |
| 162 | // of key/value pairs that can be stored globally. |
| 163 | hotCache cache |
| 164 | |
| 165 | // loadGroup ensures that each key is only fetched once |
| 166 | // (either locally or remotely), regardless of the number of |
| 167 | // concurrent callers. |
| 168 | loadGroup flightGroup |
| 169 | |
| 170 | _ int32 // force Stats to be 8-byte aligned on 32-bit platforms |
| 171 | |
| 172 | // Stats are statistics on the group. |
| 173 | Stats Stats |
| 174 | |
| 175 | // rand is only non-nil when testing, |
| 176 | // to get predictable results in TestPeers. |
| 177 | rand *rand.Rand |
| 178 | } |
| 179 | |
| 180 | // flightGroup is defined as an interface which flightgroup.Group |
| 181 | // satisfies. We define this so that we may test with an alternate |
nothing calls this directly
no outgoing calls
no test coverage detected