sorentwo / readthis

:newspaper: Pooled active support compliant caching with redis
MIT License
504 stars 40 forks source link

Add support for objects as :expires_in values #29

Closed tobinibot closed 8 years ago

tobinibot commented 8 years ago

When configuring readthis, it would be nice to be able to pass in ActiveSupport::Duration objects as the :expires_in parameter, without having to manually call the to_i method on them.

This PR adds the ability to use objects that respond to the to_i method as the :expires_in parameter. As stated above, this is mainly to support ActiveSupport::Duration objects, but there could obviously be many other uses.

tobinibot commented 8 years ago

@sorentwo I added some the additional :expires_in expansion code into the merged_options method, it seemed like a good spot because this method is called for each method that takes options. Let me know if you don’t like this approach.

tobinibot commented 8 years ago

Ok, let me rethink this whole thing. It was mostly a convenience for new users anyways. Just thought it might be nice since other stores (well, at least the default mem_store) can handle those Duration objects. Calling to_i myself is not a problem.

I’ll reopen something if I come up with something that I'm happy with and we can continue the discussion. Thanks, this has been informative and fun!