Ruby's OpenURI with Memcached for caching
Pull request Compare This branch is 3 commits behind benschwarz:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
pkg
spec
.gitignore
History.txt
License.txt
README.markdown
open-uri-memcached.gemspec

README.markdown

OpenURI with Memcached caching

Carelessly make heavy OpenURI calls as many times as you like with local memcached picking up the slack and stopping people from sending you hate mail.

Require the library using

require 'openuri/memcached'

To get started run your memcached server

$ memcached -d 

The default address that this gem will terminate against is localhost:11211, you can change this using

OpenURI::Cache.host = ['10.1.1.10:11211', '10.1.1.11:11211']

The cache defaults to 15 minutes, however this can be changed using:

OpenURI::Cache.expiry = 60 * 10 # Ten long minutes

Execution

Use exactly the same as you would openuri, only.. enable it.

require 'openuri/memcached'
OpenURI::Cache.enable!
# Slow as a wet week
open("http://germanforblack.com").read 

Quit your app (leave memcached running) and run the same example, it should now happen in less then ... some time that is really fast.

Questions and comments can be directed to ben at germanforblack.com

Requirements

  • Ruby 1.8.6
  • MemCached
  • memcache (gem)
    • You will need to ensure that you have corresponding version of libmemcached to the memcached gem installed for installation to go by breezy