Shopify/memcached_store — pull request #18 by fbogsany (2014-06-13 19:14:43+00:00)
Title: Fix serialization in MemcachedSnappyStore

### Problem
`MemcachedSnappyStore.serialize_entry` leaks state due to the refactoring in #13, which intended to pass `true` as `options[:raw]` to the message send at https://github.com/Shopify/memcached_store/blob/84aa5372728a099815a06a4519cbbb04b492d747/lib/active_support/cache/memcached_store.rb#L150. This approach led to problems "fixed" in #16 and #17.

Since the `options` hash is reused within `cas_multi`, if multiple values are stored in the hash yielded at https://github.com/Shopify/memcached_store/blob/84aa5372728a099815a06a4519cbbb04b492d747/lib/active_support/cache/memcached_store.rb#L98 then the first value will be serialized as expected, but the second and subsequent values will be serialized with `options[:raw] == true`, hence with `.to_s` instead of `Marshal.dump`.

Testing added in #17 for this problem sadly only yielded a single value in the hash.

### Solution
This extends the `cas_multi` test to yield 2 values in the hash instead of 1 (which reproduced the problem) and changes `serialize_entry` to return 2 values: the serialized value and a `raw` boolean. `cas` and `cas_multi` ignore the boolean, and no longer have their `options` hash :poop:ed on. `write_entry` passes the boolean to the subsequent message send instead of `options[:raw]`.

@camilo for review /cc @tjoyal @cjoudrey