writebehind
2015-03-31
writebehind/doc.go
First pass implementation. Create our first implementation of this. Use a map of string=>int64 to store our values. The idea here is that users will create one cache for each metric they want to collect--each column that needs updating, in MySQL land. Release it under the MIT license, because why not? Very proud that the first commit carries 100% test coverage, no golint errors, no go vet errors, and has a benchmark.
| paddy@0 | 1 /* |
| paddy@0 | 2 Package writebehind provides a cache that periodically syncs to a datastore. |
| paddy@0 | 3 |
| paddy@0 | 4 The Cache is really only useful for adding numbers that are expected to change |
| paddy@0 | 5 too frequently for a full datastore write, e.g. view counts. |
| paddy@0 | 6 |
| paddy@0 | 7 Each Cache can only be used once; calling its Stop() method renders the Cache |
| paddy@0 | 8 unusable, and a new Cache needs to be instantiated. Caches should, wherever |
| paddy@0 | 9 possible, have their Stop() methods called, or they risk leaking goroutines. |
| paddy@0 | 10 |
| paddy@0 | 11 Cache implements the expvar.Var type, and instances can be passed to |
| paddy@0 | 12 expvar.Publish to provide insight into the Cache while it's in operation. |
| paddy@0 | 13 */ |
| paddy@0 | 14 package writebehind |