{"id":16086160,"url":"https://github.com/zw963/simple_cacher","last_synced_at":"2025-04-05T14:12:03.501Z","repository":{"id":56895673,"uuid":"92915837","full_name":"zw963/simple_cacher","owner":"zw963","description":"Simple cacher/counter for ruby, use redis.","archived":false,"fork":false,"pushed_at":"2018-02-14T14:20:13.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T19:49:13.189Z","etag":null,"topics":[],"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/zw963.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T07:07:03.000Z","updated_at":"2018-09-04T11:02:10.000Z","dependencies_parsed_at":"2022-08-21T01:50:19.923Z","dependency_job_id":null,"html_url":"https://github.com/zw963/simple_cacher","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fsimple_cacher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fsimple_cacher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fsimple_cacher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fsimple_cacher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zw963","download_url":"https://codeload.github.com/zw963/simple_cacher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345857,"owners_count":20924102,"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":[],"created_at":"2024-10-09T13:10:50.548Z","updated_at":"2025-04-05T14:12:03.460Z","avatar_url":"https://github.com/zw963.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleCacher [![Build Status](https://travis-ci.org/zw963/simple_cacher.svg?branch=master)](https://travis-ci.org/zw963/simple_cacher) [![Gem Version](https://badge.fury.io/rb/simple_cacher.svg)](http://badge.fury.io/rb/simple_cacher)\n\nA very simple use/implement but very useful cacher, use Redis database.\n\n## Getting Started\n\nInstall via Rubygems\n\n    $ gem install simple_cacher\n\nOR ...\n\nAdd to your Gemfile\n\n    gem 'simple_cacher'\n\n## Usage\n\n### Use as a home page cache, expired within 120 second.\n\n```rb\n# The first step is need specify a namespace, one string which should unique each other\n# for different purpose, in this current case (one Rails controller action), `request.url'\n# is a perfect candidate.\ncacher = SimpleCacher.new(namespace: request.url)\n\nif cacher.fresh?(key: 'items')\n  @items_hash = cacher.import(key: 'items')\nelse\n  # do something get correct data and assign to a variable items_hash\n  @items_hash = cacher.export(key: 'items', data: items_hash, expire: 120)\nend\n```\n\n### Use as a counter, limit IP access during a time span.\n\n```rb\ncounter = SimpleCacher.new(namespace: 'my_api:sms_log:user_ip')\n\n# Sum IP 123.123.123.123 access count in one day, \nif counter.reach_limit?(key: '123.123.123.123', limit: 5, expire: 86400)\n  # if exceed the limit, sent a warn info\nelse\n  # do some sutff\nend\n```  \n\n## Support\n\nworked in MRI 2.[1,2,3,4], the only dependency is [redis-rb](https://github.com/redis/redis-rb)\n\n## Limitations\n\nNo known limit.\n\n## History\n\n  See [CHANGELOG](https://github.com/zw963/simple_cacher/blob/master/CHANGELOG) for details.\n\n## Contributing\n\n  * [Bug reports](https://github.com/zw963/simple_cacher/issues)\n  * [Source](https://github.com/zw963/simple_cacher)\n  * Patches:\n    * Fork on Github.\n    * Run `gem install --dev simple_cacher` or `bundle`.\n    * Create your feature branch: `git checkout -b my-new-feature`.\n    * Commit your changes: `git commit -am 'Add some feature'`.\n    * Push to the branch: `git push origin my-new-feature`.\n    * Send a pull request :D.\n\n## license\n\nReleased under the MIT license, See [LICENSE](https://github.com/zw963/simple_cacher/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzw963%2Fsimple_cacher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzw963%2Fsimple_cacher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzw963%2Fsimple_cacher/lists"}