Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Cache local configs when the argument is frozen #168

Open
saverio-kantox opened this issue Jul 6, 2017 · 2 comments
Open

[Proposal] Cache local configs when the argument is frozen #168

saverio-kantox opened this issue Jul 6, 2017 · 2 comments

Comments

@saverio-kantox
Copy link
Contributor

Often, the local config is used in several parts of an application. For example:

NY_OFFICE_CONFIG = {
  holidays: ['2017-07-04'],
  end_of_working_day: '17:00'
}.freeze

ABU_DHABI_OFFICE_CONFIG = {
  holidays: ['2017-08-08'],
  work_week: %w(sun mon tue wed thu)
}.freeze

BusinessDays::Config.with(NY_OFFICE_CONFIG) { 3.business_hours.from_now }
BusinessDays::Config.with(ABU_DHABI_OFFICE_CONFIG) { 4.business_days.ago }

Clearly, continually creating and destroying the local configs could be avoided, if the generated configs were cached. If the same frozen object is passed again, one could reuse the previous local config.

I can do that if you are interested.

@AdnanTheExcellent
Copy link

AdnanTheExcellent commented Sep 29, 2017

I am very interested in a feature of namespacing configs. we have different business hours and holidays between our customer service department and our production department, and namespaced business time configs would fix that problem.

@saverio-kantox
Copy link
Contributor Author

@AdnanTheExcellent it is already possible using exactly the syntax I wrote above. Still I would like to address the garbage issue, when one has to switch often (or by user) between different configs.

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

No branches or pull requests

2 participants