{"id":18026834,"url":"https://github.com/yegor256/zache","last_synced_at":"2025-04-09T21:18:19.747Z","repository":{"id":56899266,"uuid":"155727444","full_name":"yegor256/zache","owner":"yegor256","description":"Zero-footprint Ruby In-Memory Thread-Safe Cache: when a naive implementation is enough","archived":false,"fork":false,"pushed_at":"2025-04-07T23:50:10.000Z","size":364,"stargazers_count":47,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T21:18:15.968Z","etag":null,"topics":["cache","data-structures","memory-management","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://www.yegor256.com/2019/02/05/zache.html","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-01T14:26:53.000Z","updated_at":"2025-04-07T23:50:13.000Z","dependencies_parsed_at":"2023-12-05T13:27:03.060Z","dependency_job_id":"43605165-8863-4d07-8968-a645123d0dde","html_url":"https://github.com/yegor256/zache","commit_stats":{"total_commits":70,"total_committers":4,"mean_commits":17.5,"dds":"0.30000000000000004","last_synced_commit":"1c910afb30bd2171e3cf0277eadbd8fad1c2e0e1"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fzache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fzache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fzache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fzache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/zache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111973,"owners_count":21049578,"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":["cache","data-structures","memory-management","ruby","ruby-gem"],"created_at":"2024-10-30T08:08:13.884Z","updated_at":"2025-04-09T21:18:19.740Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# In Memory Cache for Ruby\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/zache)](https://www.rultor.com/p/yegor256/zache)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/zache/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/zache/actions/workflows/rake.yml)\n[![Gem Version](https://badge.fury.io/rb/zache.svg)](https://badge.fury.io/rb/zache)\n[![Maintainability](https://api.codeclimate.com/v1/badges/c136afe340fa94f14696/maintainability)](https://codeclimate.com/github/yegor256/zache/maintainability)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/zache/master/frames)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/zache/blob/master/LICENSE.txt)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/zache.svg)](https://codecov.io/github/yegor256/zache?branch=master)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/zache)](https://hitsofcode.com/view/github/yegor256/zache)\n\nThis is a simple Ruby gem for in-memory caching.\nRead [this blog post](https://www.yegor256.com/2019/02/05/zache.html)\nto understand what Zache is designed for.\n\nFirst, install it:\n\n```bash\ngem install zache\n```\n\nThen, use it like this:\n\n```ruby\nrequire 'zache'\nzache = Zache.new\n# Expires in 5 minutes\nv = zache.get(:count, lifetime: 5 * 60) { expensive() }\n```\n\nIf you omit the `lifetime` parameter, the key will never expire.\n\nBy default `Zache` is thread-safe. It locks the entire cache on each\n`get` call. You can turn that off by using the `sync` argument:\n\n```ruby\nzache = Zache.new(sync: false)\nv = zache.get(:count) { expensive() }\n```\n\nYou may use \"dirty\" mode, which will return an expired value while\ncalculation is in progress. For example, if you have a value in the cache that's\nexpired, and you call `get` with a long-running block, the thread waits.\nIf another thread calls `get` again, that second thread won't wait, but will\nreceive the expired value from the cache. This is a very convenient mode for situations\nwhere absolute data accuracy is less important than performance.\n\nThe entire API is documented\n[here](https://www.rubydoc.info/github/yegor256/zache/master/Zache)\n(there are many other convenient methods).\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 2.3+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fzache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fzache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fzache/lists"}