{"id":18317184,"url":"https://github.com/ibotta/atomic_cache","last_synced_at":"2025-04-05T21:32:14.295Z","repository":{"id":29469125,"uuid":"119417861","full_name":"Ibotta/atomic_cache","owner":"Ibotta","description":"a gem which prevents the thundering herd problem","archived":false,"fork":false,"pushed_at":"2023-05-05T16:00:39.000Z","size":213,"stargazers_count":8,"open_issues_count":4,"forks_count":6,"subscribers_count":90,"default_branch":"main","last_synced_at":"2025-03-21T12:06:28.971Z","etag":null,"topics":["atomic-cache","cache","rubygem","thundering-herd"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ibotta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-29T17:42:52.000Z","updated_at":"2024-01-08T05:33:57.000Z","dependencies_parsed_at":"2023-01-14T14:59:58.447Z","dependency_job_id":null,"html_url":"https://github.com/Ibotta/atomic_cache","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ibotta%2Fatomic_cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ibotta%2Fatomic_cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ibotta%2Fatomic_cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ibotta%2Fatomic_cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ibotta","download_url":"https://codeload.github.com/Ibotta/atomic_cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406032,"owners_count":20933803,"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","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":["atomic-cache","cache","rubygem","thundering-herd"],"created_at":"2024-11-05T18:05:19.822Z","updated_at":"2025-04-05T21:32:13.727Z","avatar_url":"https://github.com/Ibotta.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# atomic_cache Gem\n[![Gem Version](https://badge.fury.io/rb/atomic_cache.svg)](https://badge.fury.io/rb/atomic_cache)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/790faad5866d2a00ca6c/test_coverage)](https://codeclimate.com/github/Ibotta/atomic_cache/test_coverage)\n\n## User Documentation\n * [Installation \u0026 Project Setup](docs/PROJECT_SETUP.md)\n * [Model Setup](docs/MODEL_SETUP.md)\n * [Usage \u0026 Testing](docs/USAGE.md)\n * [Custom Clients/Adapters](docs/INTERFACES.md)\n\n#### atomic_cache is a gem which prevents the [thundering herd problem](https://en.wikipedia.org/wiki/Thundering_herd_problem)\nIn a nutshell:\n * The key of every cached value includes a timestamp\n * Once a cache key is written to, it is never written over\n * When a newer version of a cached value is available, it's written to a new key (e.g. same key with a newer timestamp)\n * When a new value is being generated for a new key only 1 process is allowed to do so at a time\n * While the new value is being generated, other processes read one key older than most recent (last known value)\n * If the last known value isn't available other processes wait for the new value, polling periodically for it\n\n#### Quick Reference\n```ruby\nclass Foo \u003c ActiveRecord::Base\n  include AtomicCache::GlobalLMTCacheConcern\n\n  force_cache_class(:custom_foo)  # optional\n  cache_version(5)          # optional\n\n  def active_foos(ids)\n    keyspace = cache_keyspace(:activeids, ids)\n    atomic_cache.fetch(keyspace, expires_in: 5.minutes) do\n      Foo.active.where(id: ids.uniq)\n    end\n\n    # value stored at 'company:custom_foo:activeids:\u003cids hash\u003e:1270643035.04671'\n    # last mod time stored at 'company:custom_foo:lmt'\n  end\nend\n```\nFor further details and examples see [Usage \u0026 Testing](docs/USAGE.md)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ibotta/atomic_cache\n\n## Releasing\n\nReleases are automatically handled via the Travis CI build. When a version greater than\nthe version published on rubygems.org is pushed to the `main` branch, Travis will:\n\n- re-generate the CHANGELOG file\n- tag the release with GitHub\n- release to rubygems.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibotta%2Fatomic_cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibotta%2Fatomic_cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibotta%2Fatomic_cache/lists"}