Path: | lib/memcache.rb (CVS) |
Last Update: | Thu Aug 25 14:54:49 MDT 2005 |
A Ruby client library for memcached (memory cache daemon)
require 'memcache' cache = MemCache::new '10.0.0.15:11211', '10.0.0.15:11212', '10.0.0.17:11211:3', # weighted :debug => true, :c_threshold => 100_000, :compression => false, :namespace => 'foo' cache.servers += [ "10.0.0.15:11211:5" ] cache.c_threshold = 10_000 cache.compression = true # Cache simple values with simple String or Symbol keys cache["my_key"] = "Some value" cache[:other_key] = "Another value" # ...or more-complex values cache["object_key"] = { 'complex' => [ "object", 2, 4 ] } # ...or more-complex keys cache[ Time::now.to_a[1..7] ] ||= 0 # ...or both cache[userObject] = { :attempts => 0, :edges => [], :nodes => [] } val = cache["my_key"] # => "Some value" val = cache["object_key"] # => {"complex" => ["object",2,4]} print val['complex'][2] # => 4
Thanks to Martin Chase and Rick Bradley for peer review, bugfixes, and suggestions.
Copyright © 2003-2005 The FaerieMUD Consortium. All rights reserved.
This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby.
$Id: memcache.rb 72 2005-08-25 15:14:18Z ged $