cliss/accidentalbot — pull request #33 by bradchoate (2014-07-01 07:17:41+00:00)
Title: Memcached changeset (rebased)

Includes a bit of refactoring to minimize the amount of data per title we cache, since all titles are cached under a single key. Even with a 1 MB limit per key, this will hold a lot of titles. Caching is automatically enabled if a `MEMCACHED_SERVERS` (or `MEMCACHIER_SERVERS`) environment variable is set. If caching is not enabled, the bot still works as it did before.

The list of IPs that voted for each title is stored in a separate key, again to minimize the amount of data placed in the titles data structure, but also to limit writes to the titles key, so we aren't updating the larger structure in Memcached for each vote. Similarly, vote counts are stored separately as well.

Finally, there is a bit of sanity checking done for submitted links (including an overall limit to the link length).

Hopefully, this squashed and rebased pull request is easier to review. In addition to simple persistence via cache, we should look at a proper key/value storage service or a real, honest-to-goodness database.