{"id":14955994,"url":"https://github.com/freshworks/memoize_until","last_synced_at":"2025-07-26T06:08:18.196Z","repository":{"id":53715280,"uuid":"107949452","full_name":"freshworks/memoize_until","owner":"freshworks","description":"This gem is an extension to the standard memoization pattern.","archived":false,"fork":false,"pushed_at":"2025-05-05T01:05:20.000Z","size":51,"stargazers_count":1,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-08T12:12:49.386Z","etag":null,"topics":["cache","memoize","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freshworks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-10-23T07:54:29.000Z","updated_at":"2023-04-17T11:29:59.000Z","dependencies_parsed_at":"2023-07-15T15:18:44.746Z","dependency_job_id":null,"html_url":"https://github.com/freshworks/memoize_until","commit_stats":null,"previous_names":["freshdesk/memoize_until"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/freshworks/memoize_until","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshworks%2Fmemoize_until","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshworks%2Fmemoize_until/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshworks%2Fmemoize_until/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshworks%2Fmemoize_until/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freshworks","download_url":"https://codeload.github.com/freshworks/memoize_until/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshworks%2Fmemoize_until/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267127832,"owners_count":24040142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","memoize","rails","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:12:08.883Z","updated_at":"2025-07-26T06:08:18.124Z","avatar_url":"https://github.com/freshworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MemoizeUntil\n\nThis gem is an extension to the standard `memoization` pattern for storing expensive computations or network calls `in-memory`. Unlike other memoization extensions which expire after a pre-defined interval, this gem provides a consistent memoization behavior across multiple processes/servers i.e. keys expire simultaneously across all processes.\n\nUsage:\n```ruby\ngem install memoize_until\n\u003e irb\nirb:\u003e require 'memoize_until'\nirb:\u003e result = MemoizeUntil.day(:default) do\nirb:\u003e \t# PerformSomeComplexOperation\nirb:\u003e end # memoizes(until the end of the day) and returns the result of #PerformSomeComplexOperation\nirb:\u003e p result.inspect\n```\n\nThe default API that the gem provides is: `MemoizeUntil#min, MemoizeUntil#hour, MemoizeUntil#day, MemoizeUntil#week, MemoizeUntil#month` with `default` purposes(keys). \n\nTo add new purposes during run_time, you can also leverage the `add_to` API:\n```ruby\nirb:\u003e MemoizeUntil.add_to(:day, :runtime_key) \nirb:\u003e result = MemoizeUntil.day(:runtime_key) do\nirb:\u003e \t# PerformSomeComplexRuntimeOperation\nirb:\u003e end # memoizes(until the end of the day) and returns the result of #PerformSomeComplexOperation\nirb:\u003e p result.inspect\n```\nThe same can be done for other default kinds as well: `min, hour, week, month`\n\n## Rails\n\nTo use this gem in a rails application, add the following line to your `Gemfile` and you are good to go.\n\n```ruby\ngem 'memoize_until'\n```\n\nFor most use cases, the list of purposes that come will not suffice. You can define your custom list of config purposes that you wish to memoize for, by including a `config/memoize_until.yml` in the root directory of your application. Here is an [example](/examples/memoize_until.yml) to help you with the file structure. \n\n## Testing\n\nTo clear the currently memoized value for a purpose, you can use the `clear_now` API.\n\n```ruby\nirb:\u003e MemoizeUntil.day(:default) { 1 } # 1\nirb:\u003e MemoizeUntil.clear_now_for(:day, :default) \nirb:\u003e MemoizeUntil.day(:default) { 2 } # 2\n```\n\n#### Note: This API only clears the currently memoized value in the current running process and will not mitigate to other processes in a multiprocess world. This is recommended to be used only for testing setup.\n\n## Contributing\nTo run test cases,\n```shell\nbundle install\nruby -Ilib:test test/memoize_until_test.rb\n```\n\nThis project is Licensed under the MIT License. Further details can be found [here](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshworks%2Fmemoize_until","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreshworks%2Fmemoize_until","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshworks%2Fmemoize_until/lists"}