This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Evan Weaver (author)
Wed May 27 23:54:54 -0700 2009
commit e157b74c5450f4d09f0a2e0ee57574622065ed49
tree 80513e854b838f2ca4644d1e3e951f3710656092
parent 1435a02243eb17bd52e7397fe418f65464835f3d
tree 80513e854b838f2ca4644d1e3e951f3710656092
parent 1435a02243eb17bd52e7397fe418f65464835f3d
| name | age | message | |
|---|---|---|---|
| |
BENCHMARKS | Sat Mar 08 16:33:59 -0800 2008 | |
| |
CHANGELOG | ||
| |
COMPATIBILITY | ||
| |
LICENSE | Sun Jan 20 01:16:17 -0800 2008 | |
| |
Manifest | Mon Jul 14 12:13:38 -0700 2008 | |
| |
README | Thu Feb 05 17:13:24 -0800 2009 | |
| |
Rakefile | Sun Feb 03 12:18:20 -0800 2008 | |
| |
TODO | Sun Jun 22 02:02:51 -0700 2008 | |
| |
ext/ | ||
| |
lib/ | ||
| |
test/ |
README
memcached An interface to the libmemcached C client. == License Copyright 2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Portions copyright 2008 TangentOrg, Brian Aker, licensed under the BSD license, and used with permission. The public certificate for this gem is here[http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem]. If you use this software, please {make a donation}[http://blog.evanweaver.com/donate/], or {recommend Evan}[http://www.workingwithrails.com/person/7739-evan-weaver] at Working with Rails. == Features * clean API * robust access to all memcached features * multiple hashing modes, including consistent hashing * ludicrous speed, including optional non-blocking IO The <b>memcached</b> library wraps the pure-C libmemcached client via SWIG. == Installation You need Ruby 1.8.6, and {libmemcached 0.25}[http://tangent.org/552/libmemcached.html]. Other versions are not guaranteed to work. You also need {memcached itself}[http://www.danga.com/memcached/] if you want to test against a local server. For Linux, download and extract the {libmemcached tarball}[http://download.tangent.org/libmemcached-0.25.tar.gz]. Then run: ./configure make && sudo make install For OS X, you may be able to install it from MacPorts: sudo port install libmemcached @0.25 Now install the gem: sudo gem install memcached --no-rdoc --no-ri Note that on OS X 10.5 you may need to set the architecture explicitly: sudo env ARCHFLAGS="-arch i386" gem install memcached --no-rdoc --no-ri == Usage Start a local memcached server: $ memcached -p 11211 & 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"} You can set a counter and increment it: start = 1 $cache.set 'counter', start, 0, false $cache.increment 'counter' #=> 2 $cache.increment 'counter' #=> 3 $cache.get('counter', false).to_i #=> 3 You can get some server stats: $cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...} Note that the API is not the same as that of <b>Ruby-MemCache</b> or <b>memcache-client</b>. In particular, <tt>nil</tt> is a valid record value. Memcached#get does not return <tt>nil</tt> on failure, rather it raises <b>Memcached::NotFound</b>. This is consistent with the behavior of memcached itself. For example: $cache.set 'test', nil $cache.get 'test' #=> nil $cache.delete 'test' $cache.get 'test' #=> raises Memcached::NotFound == Legacy applications There is a compatibility wrapper for legacy applications called Memcached::Rails. == Threading <b>memcached</b> is threadsafe, but each thread requires its own Memcached instance. Create a global Memcached, and then call Memcached#clone each time you spawn a thread. thread = Thread.new do cache = $cache.clone # Perform operations on cache, not $cache cache.set 'example', 1 cache.get 'example' # ... cache.destroy end # Join the thread so that exceptions don't get lost thread.join == Benchmarks <b>memcached</b> is up to 150x faster than <b>memcache-client</b>, and up to 15x faster than <b>caffeine</b>. See BENCHMARKS[link:files/BENCHMARKS.html] for details. == Reporting problems The support forum is here[http://rubyforge.org/forum/forum.php?forum_id=20894]. Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC. == Further resources * {Memcached wiki}[http://www.socialtext.net/memcached/index.cgi] * {Libmemcached homepage}[http://tangent.org/552/libmemcached.html]








