Sha256: 7b3a97a97880d46ea0c7eb2a5c12f1a2cac3ce86dd74982d7fd8041b72b552a6
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# Matador [![Build Status](https://travis-ci.org/StevenJL/matador.svg?branch=master)](https://travis-ci.org/StevenJL/matador) Stop cache expiration triggered [thundering herd](https://en.wikipedia.org/wiki/Thundering_herd_problem) problems with Matador. Currently works with redis. ## Installation Add this line to your application's Gemfile: gem 'matador' And then execute: $ bundle Or install it yourself as: $ gem install matador ## Usage Set your cache service object (currently only supports redis) ```ruby require "matador" require "redis" $redis = Redis.new(host: "127.0.0.1", port: "16379") Matador.cache_store = $redis ``` Caching with an expiration is susceptible to a thundering herd in high traffic situations: ```ruby data = time_consuming_operation(...) $redis.set("some_key", data) $redis.expire("some_key", 120) ``` Wrap it in matador. When the cache expires after 2 minutes, the first request goes through to generate the new cache. While the new cache is being built (next 10 seconds), all other requests are served the stale cache. ```ruby Matador.fetch("some_key", :ttl => 120, :therd_ttl => 10) do time_consuming_operation end ``` ## TO DO 1. Integrate with Memcache ## Contributing 1. Fork it ( http://github.com/<my-github-username>/matador/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matador-0.0.1 | README.md |