Skip to content

Conversation

@jorgemanrubia
Copy link
Collaborator

@jorgemanrubia jorgemanrubia commented Apr 13, 2022

This adds support to generate keys via a method name passed as a symbol:

class Person
  kredis_list :names, key: :generate_key

  private
    def generate_key
      "some generated key"
    end
end

Currently, the only way to customize keys is via a lambda, lilke key: ->(p) { "person:#{p.id}:names_customized" }. The problem with that approach is that, when you want to invoke a method to determine the key, you need to make that method public. This is also a more concise way of covering a pretty common use case: using an instance method to determine keys.

@jeremy jeremy merged commit cbdc2cc into rails:main Apr 25, 2022
@jeremy jeremy deleted the key-method branch April 25, 2022 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants