No commit activity in last 3 years
No release in over 3 years
A JRuby extension wrapping the latest spymemcached client (v2.11.4).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
>= 0.9.2, ~> 0.9
 Project Readme

Spymemcached.jruby

Built with 💛 and ☕ in San Francisco

A JRuby extension wraps the latest spymemcached client. Fastest jruby memcached client, threadsafe.

Usage

Start a local networked memcached server:

$ memcached -p 11211

Require the library and instantiate a Spymemcached object at a global level:

require 'spymemcached'
$cache = Spymemcached.new("localhost:11211")

Setup multiple servers with options

require 'spymemcached'
$cache = Spymemcached.new(['memcached1.host:11211', 'memcached2.host:11211', 'memcached3.host:11211'],
                          {:namespace => 'appName', :timeout => 0.1, :binary => true})

Valid +options+ are:

[:namespace]        Prepends this value to all keys added or retrieved.
[:timeout]          Time to use as the socket read timeout, seconds.  Defaults to 0.5 sec.
[:binary]           Talks binary protocol with Memcached server. Default to true.
[:should_optimize]  If true, Spymemcached low-level optimization is in effect. Default to false.

Rails 4

Use spymemcached_store gem to integrate ActiveSupport cache store and spymemcached.jruby gem.

Rails 3

require 'spymemcached'
config.cache_store = :mem_cache_store, Spymemcached.new(servers, options).rails23

Rails 2.x

require 'spymemcached'
ActionController::Base.cache_store = :mem_cache_store, Spymemcached.new(servers, options).rails23

Default behaviors

Spymemcached.jruby applies:

  • Ketama key hash algorithm (see Spymemcached document or RJ's blog post for details)
  • Gzip compressed when the cache data size is larger than 16kb.
  • Binary protocol

Other default settings see Spymemcached DefaultConnectionFactory for details.

Performance

Benchmark result compared with gem dalli and jruby-memcached

Further resources