redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
124 stars 60 forks source link

Add note about casting ttl values to integer #155

Closed jamesgecko closed 10 months ago

jamesgecko commented 10 months ago

The changelog mentions that TTL values are cast to int, but this information is not present in the types section of the README. Adding the info with an example.

byroot commented 10 months ago

That's not correct. There is no such thing as TTL values, here you are passing an ActiveSupport::Duration instance. And there is no special handling about them.

jamesgecko commented 10 months ago

Sorry, I was trying to copy the language from the changelog, but maybe there's a better way to state it.

The Integer casting added to various duration-related functions in 5.0.4 does operate on ActiveRecord::Duration because of duck typing; the cast returns the duration in seconds as an integer. I can change the example if you'd prefer something less Rails-y?

byroot commented 10 months ago

Yes. But also note you are linking to the redis gem, which define a speciific method for each command, so it know what the expected type is, so it can cast to integer where an integer is expected.

Here we're commenting in redis-client, which is lower level and doesn't know anything about command signatures and what the expected types are, hence why it only as very simplistic and generic casting rules.