Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 125 lines (79 sloc) 4.171 kb
1be9c9d5 »
2014-03-17 Update README [skip ci]
1 = memcached
5d3b5f08 »
2008-01-19 readme
2
c1043e70 »
2008-01-20 description
3 An interface to the libmemcached C client.
5d3b5f08 »
2008-01-19 readme
4
287f407a »
2013-06-14 Adds support for Travis CI.
5 {<img src="https://travis-ci.org/evan/memcached.png" alt="Build Status" />}[https://travis-ci.org/evan/memcached]
6
5d3b5f08 »
2008-01-19 readme
7 == License
8
c0d9025c »
2013-06-10 Copyright
9 Copyright 2009-2013 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Portions copyright 2007-2009 TangentOrg, Brian Aker, licensed under the BSD license, and used with permission.
5d3b5f08 »
2008-01-19 readme
10
11 == Features
12
b016fc48 »
2008-01-20 delete needed missing test
13 * clean API
a79cf8b1 »
2008-01-20 rename
14 * robust access to all memcached features
61d5c538 »
2012-02-26 Readme.
15 * SASL support for the binary protocol
5d3b5f08 »
2008-01-19 readme
16 * multiple hashing modes, including consistent hashing
02288c19 »
2010-08-31 Update benchmarks again.
17 * ludicrous speed, including optional pipelined IO with no_reply
167e80ea »
2008-01-21 benchmarks don't thrash server into the ground
18
e8cff058 »
2008-02-03 Snazzier benchmark script.
19 The <b>memcached</b> library wraps the pure-C libmemcached client via SWIG.
5d3b5f08 »
2008-01-19 readme
20
1e86748c »
2008-01-20 readme
21 == Installation
5d3b5f08 »
2008-01-19 readme
22
38cbf1a8 »
2012-01-12 You need `gettext` to build on Lucid
23 You need Ruby 1.8.7 or Ruby 1.9.2. Other versions may work, but are not guaranteed. You also need the `libsasl2-dev` and `gettext` libraries, which should be provided through your system's package manager.
5d3b5f08 »
2008-01-19 readme
24
081141a9 »
2009-08-03 Manifest; clean; extconf.rb.
25 Install the gem:
c1ef0721 »
2008-01-21 use tmp for log location
26 sudo gem install memcached --no-rdoc --no-ri
de98549c »
2011-02-27 Readme.
27
5d3b5f08 »
2008-01-19 readme
28 == Usage
29
fe979084 »
2008-11-18 updated to describe unix domain sockets
30 Start a local networked memcached server:
80c113db »
2008-01-20 test buffered_requests and no_block
31 $ memcached -p 11211 &
9826d840 »
2008-01-20 some usage
32
eb954bf4 »
2008-01-20 readme
33 Now, in Ruby, require the library and instantiate a Memcached object at a global level:
34
35 require 'memcached'
5dd8e2b9 »
2009-08-03 Better inspect.
36 $cache = Memcached.new("localhost:11211")
de98549c »
2011-02-27 Readme.
37
eb954bf4 »
2008-01-20 readme
38 Now you can set things and get things:
de98549c »
2011-02-27 Readme.
39
eb954bf4 »
2008-01-20 readme
40 value = 'hello'
41 $cache.set 'test', value
42 $cache.get 'test' #=> "hello"
43
44 You can set with an expiration timeout:
45
46 value = 'hello'
47 $cache.set 'test', value, 1
48 sleep(2)
49 $cache.get 'test' #=> raises Memcached::NotFound
50
51 You can get multiple values at once:
52
53 value = 'hello'
54 $cache.set 'test', value
94f4d2b8 »
2008-02-09 Clearer multiget example.
55 $cache.set 'test2', value
de98549c »
2011-02-27 Readme.
56 $cache.get ['test', 'test2', 'missing']
94f4d2b8 »
2008-02-09 Clearer multiget example.
57 #=> {"test" => "hello", "test2" => "hello"}
de98549c »
2011-02-27 Readme.
58
b4a535f6 »
2011-03-03 Docs
59 You can set a counter and increment it. Note that you must initialize it with an integer, encoded as an unmarshalled ASCII string:
eb954bf4 »
2008-01-20 readme
60
61 start = 1
b4a535f6 »
2011-03-03 Docs
62 $cache.set 'counter', start.to_s, 0, false
eb954bf4 »
2008-01-20 readme
63 $cache.increment 'counter' #=> 2
64 $cache.increment 'counter' #=> 3
65 $cache.get('counter', false).to_i #=> 3
66
67 You can get some server stats:
68
80c113db »
2008-01-20 test buffered_requests and no_block
69 $cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
de98549c »
2011-02-27 Readme.
70
80c113db »
2008-01-20 test buffered_requests and no_block
71 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:
eb954bf4 »
2008-01-20 readme
72
73 $cache.set 'test', nil
74 $cache.get 'test' #=> nil
75 $cache.delete 'test'
76 $cache.get 'test' #=> raises Memcached::NotFound
80c113db »
2008-01-20 test buffered_requests and no_block
77
e4992e7f »
2014-02-22 Add memcached_store gem to readme [skip ci]
78 == Rails 3 and 4
df2d109c »
2012-07-10 add rails instructions
79
e4992e7f »
2014-02-22 Add memcached_store gem to readme [skip ci]
80 Use {memcached_store gem}[https://github.com/Shopify/memcached_store] to integrate ActiveSupport cache store and memcached gem
df2d109c »
2012-07-10 add rails instructions
81
bcb65337 »
2011-03-02 README
82 == Pipelining
e57d4deb »
2008-02-02 Add rake task for valgrind; update README.
83
f74aaa53 »
2011-03-03 Readme
84 Pipelining updates is extremely effective in <b>memcached</b>, leading to more than 25x write throughput than the default settings. Use the following options to enable it:
bcb65337 »
2011-03-02 README
85
86 :no_block => true,
87 :buffer_requests => true,
88 :noreply => true,
89 :binary_protocol => false
90
91 Currently #append, #prepend, #set, and #delete are pipelined. Note that when you perform a read, all pending writes are flushed to the servers.
e57d4deb »
2008-02-02 Add rake task for valgrind; update README.
92
eb954bf4 »
2008-01-20 readme
93 == Threading
9826d840 »
2008-01-20 some usage
94
0727a0a8 »
2008-01-21 use best x86-64 stats
95 <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.
9826d840 »
2008-01-20 some usage
96
eb954bf4 »
2008-01-20 readme
97 thread = Thread.new do
98 cache = $cache.clone
99 # Perform operations on cache, not $cache
100 cache.set 'example', 1
101 cache.get 'example'
de98549c »
2011-02-27 Readme.
102 end
eb954bf4 »
2008-01-20 readme
103
a9a15728 »
2008-01-21 dont use rdoc heredocs bc i cant tell where the code starts and ends …
104 # Join the thread so that exceptions don't get lost
eb954bf4 »
2008-01-20 readme
105 thread.join
de98549c »
2011-02-27 Readme.
106
bcb65337 »
2011-03-02 README
107 == Legacy applications
108
109 There is a compatibility wrapper for legacy applications called Memcached::Rails.
110
4dcf1aa9 »
2008-01-20 resources
111 == Benchmarks
112
609a8f29 »
2013-06-04 Fix link to BENCHMARKS file
113 <b>memcached</b>, correctly configured, is at least twice as fast as <b>memcache-client</b> and <b>dalli</b>. See link:BENCHMARKS for details.
4dcf1aa9 »
2008-01-20 resources
114
5d3b5f08 »
2008-01-19 readme
115 == Reporting problems
116
a85809ff »
2012-02-19 Tracker url.
117 The support forum is here[http://github.com/evan/memcached/issues].
5d3b5f08 »
2008-01-19 readme
118
119 Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.
120
121 == Further resources
122
13c50786 »
2013-09-13 Links
123 * {Memcached wiki}[https://code.google.com/p/memcached/wiki/NewStart]
124 * {Libmemcached homepage}[libmemcached.org]
Something went wrong with that request. Please try again.