{"id":20516380,"url":"https://github.com/eirc/sane_memcached_ttl","last_synced_at":"2026-04-16T23:33:25.891Z","repository":{"id":22674738,"uuid":"26018225","full_name":"eirc/sane_memcached_ttl","owner":"eirc","description":"Add sanity to memcached expiration times.","archived":false,"fork":false,"pushed_at":"2014-10-31T15:41:28.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T18:54:31.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/eirc.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}},"created_at":"2014-10-31T13:57:02.000Z","updated_at":"2014-10-31T13:57:23.000Z","dependencies_parsed_at":"2022-08-21T01:20:28.943Z","dependency_job_id":null,"html_url":"https://github.com/eirc/sane_memcached_ttl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eirc%2Fsane_memcached_ttl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eirc%2Fsane_memcached_ttl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eirc%2Fsane_memcached_ttl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eirc%2Fsane_memcached_ttl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eirc","download_url":"https://codeload.github.com/eirc/sane_memcached_ttl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242119527,"owners_count":20074757,"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-11-15T21:28:34.513Z","updated_at":"2026-04-16T23:33:25.782Z","avatar_url":"https://github.com/eirc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SaneMemcachedTtl\n\n[![Build Status](https://travis-ci.org/eirc/sane_memcached_ttl.svg?branch=v0.0.1)](https://travis-ci.org/eirc/sane_memcached_ttl)\n[![Code Climate](https://codeclimate.com/github/eirc/sane_memcached_ttl/badges/gpa.svg)](https://codeclimate.com/github/eirc/sane_memcached_ttl)\n[![Gem Version](https://badge.fury.io/rb/sane_memcached_ttl.svg)](http://badge.fury.io/rb/sane_memcached_ttl)\n[![Dependency Status](https://gemnasium.com/eirc/sane_memcached_ttl.svg)](https://gemnasium.com/eirc/sane_memcached_ttl)\n![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/sane_memcached_ttl)\n\nWork around memcached's [feature](https://code.google.com/p/memcached/wiki/NewProgramming#Expiration) of treating expiration times larger than one month as timestamps for Rails cache stores.\n\nThis is a memcached documented behaviour:\n\n* Store a key with expiration time of 10 seconds\n* Retrieve key ~\u003e you get it\n* Wait 10 seconds\n* Retrieve key ~\u003e you don't get it\n\nmakes sense... but:\n\n* Store a key with expiration time of 3.000.000 seconds (about 35 days)\n* Retrieve key ~\u003e you **don't** get it\n\n3.000.000 is treated as timestamp, so the key expired at 1970-02-04 17:20:00 (3.000.000 seconds after the UNIX epoch). So when you want to store something with an expiration time larger than a month you have to convert the expiration time to a proper timestamp. This is annoying and it even becomes impossible when you want to set default expiration times on stores.\n\nThis gem provides additional cache stores, subclasses of the original ones altering this behaviour for sanity.\n\nSupported cache stores: couchbase_store, dalli_store, mem_cache_store.\n\n## Dalli note\n\nThe dalli store actually fixed this on version 2.7.1 but it's kinda debated ([issue #436](https://github.com/mperham/dalli/issues/436)) on whether this should stay in as it's a documented memcached \"feature\" and clients should probably be not alter to these things.\n\nSo **don't** use this if your dalli gem version is \u003e= 2.7.1.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sane_memcached_ttl'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install sane_memcached_ttl\n\n## Usage\n\nWhen defining a Rails cache store like:\n\n```ruby\nconfig.cache_store = :mem_cache_store, \"cache-1.example.com\", \"cache-2.example.com\"\n```\n\njust change to:\n\n```ruby\nconfig.cache_store = :mem_cache_store_with_sane_ttl, \"cache-1.example.com\", \"cache-2.example.com\"\n```\n\nSame for all supported stores:\n\n| Original store    | Sane store                        |\n| ----------------- | --------------------------------- |\n| `mem_cache_store` | `mem_cache_store_with_sane_ttl`   |\n| `dalli_store`     | `dalli_store_store_with_sane_ttl` |\n| `couchbase_store` | `couchbase_store_with_sane_ttl`   |\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/sane_memcached_ttl/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feirc%2Fsane_memcached_ttl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feirc%2Fsane_memcached_ttl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feirc%2Fsane_memcached_ttl/lists"}