Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

fastest jruby memcached client

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 src
Octocat-spinner-32 target
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGELOG.md
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 benchmark.rb
Octocat-spinner-32 jruby_memcached.gemspec
Octocat-spinner-32 pom.xml
README.md

jruby-memcached

A jruby memcached gem which is compatible with evan's memcached gem

Install

gem install jruby-memcached

Usage

Now, in Ruby, require the library and instantiate a Memcached object at a global level:

require 'memcached'
$cache = Memcached.new("localhost:11211")

Now you can set things and get things:

value = 'hello'
$cache.set 'test', value
$cache.get 'test' #=> "hello"

You can set with an expiration timeout:

value = 'hello'
$cache.set 'test', value, 1
sleep(2)
$cache.get 'test' #=> raises Memcached::NotFound

You can get multiple values at once:

value = 'hello'
$cache.set 'test', value
$cache.set 'test2', value
$cache.get ['test', 'test2', 'missing']
  #=> {"test" => "hello", "test2" => "hello"}

Rails

# config/environment.rb config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])

Benchmarks

memcached.gem is the fastest memcached gem in MRI, jruby-memcached is the fastest memcached gem in JRuby. See benchmark

Something went wrong with that request. Please try again.