mperham/dalli — pull request #211 by twinturbo (2012-05-08 07:53:29+00:00)
Title: Expanded cache keys

I recently came across a bug in Dalli. `ActiveSupport::Cache` implementations expand cache keys. That means they do some logic on the values to generate a string if it's not a string. The most notable case is passing in an `ActiveRecord` object and it will generate a unique key for that object. For example,

```ruby
Rails.cache.write @user, "foo"
# writes "users/1/483214987348" class/id/timestamp to the cache

# you can also pass in arrays
Rails.cache.write [@user, @user.child], "foo"
#writes users/1/2348832/users/2/23849887 to the cache
```

Dalli defaults to simply calling `#to_s` on the key which was causing some very weird bugs in my application.

This PR makes Dalli expand cache keys (code taken directly from `ActiveSupport::Cache` since you've elected to not inherit). This should make Dalli more compatibile with the `ActiveSupport::Cache` interface.