Skip to content

Evaluate Proc namespaces every time (not just at initialization)#923

Merged
petergoldstein merged 1 commit intopetergoldstein:mainfrom
marketplacer:nigelw/evaluate-proc-namespace-every-time
Jun 28, 2022
Merged

Evaluate Proc namespaces every time (not just at initialization)#923
petergoldstein merged 1 commit intopetergoldstein:mainfrom
marketplacer:nigelw/evaluate-proc-namespace-every-time

Conversation

@nrw505
Copy link
Copy Markdown
Contributor

@nrw505 nrw505 commented Jun 22, 2022

When creating a dalli client with a Proc for the namespace option, it
would generally mean that the namespace may change from operation to
operation. Saving the result of calling the proc in the KeyManager
instance at initialisation time means that the client will always use
the value of the namespace as it was when the client was created. If
this was the desired behaviour, it would be just as easy to pass that
value as a string instead of a Proc.

Given test/test_key_manager.rb:69 is passing a namespace_as_symbol instead of namespace_as_proc, I'm assuming this is an unintended regression from when this logic was pulled out into KeyManager

When creating a dalli client with a Proc for the namespace option, it
would generally mean that the namespace may change from operation to
operation. Saving the result of calling the proc in the KeyManager
instance at initialisation time means that the client will always use
the value of the namespace as it was when the client was created. If
this was the desired behaviour, it would be just as easy to pass that
value as a string instead of a Proc.
@petergoldstein
Copy link
Copy Markdown
Owner

@nrw505 This all looks correct. Thanks for catching the issue and contributing a fix. Merging.

@petergoldstein petergoldstein merged commit f5ec74c into petergoldstein:main Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants