kredis icon indicating copy to clipboard operation
kredis copied to clipboard

Feature: delegate ID

Open lewispb opened this issue 1 year ago • 0 comments

Currently Kredis supports manually constructing a key, this is often required to capture the relationship between a user and an object:

class Widgets::Selection
  kredis_set :selected_widgets, typed: :integer, key: ->(selection) { "identity:#{selection.identity.id}:selected_widgets" }

  attr_accessor :identity
end

It'd be nice if Kredis supported this common scenario, generating an appropriately scoped key (useful for any future incineration):

class Widgets::Selection
  kredis_set :selected_widgets, typed: :integer, identified_by: :identity

  attr_accessor :identity
end

lewispb avatar Aug 10 '23 11:08 lewispb