evented-memcache-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +113 -0
- data/COPYING +348 -0
- data/README +75 -0
- data/Rakefile +123 -0
- data/doc/classes/EventMachine.html +146 -0
- data/doc/classes/EventMachine/Protocols.html +135 -0
- data/doc/classes/EventMachine/Protocols/Memcache.html +153 -0
- data/doc/classes/EventMachine/Protocols/Memcache/Client.html +121 -0
- data/doc/classes/EventMachine/Protocols/Memcache/Connectable.html +615 -0
- data/doc/classes/EventMachine/Protocols/Memcache/Connection.html +192 -0
- data/doc/classes/EventMachine/Protocols/Memcache/Sender.html +389 -0
- data/doc/classes/EventMachine/Protocols/Memcache/Server.html +463 -0
- data/doc/classes/EventMachine/Protocols/Memcache/TenaciousMC.html +277 -0
- data/doc/classes/MyHandler.html +197 -0
- data/doc/created.rid +1 -0
- data/doc/files/COPYING.html +473 -0
- data/doc/files/README.html +187 -0
- data/doc/files/extras/consumer_rb.html +110 -0
- data/doc/files/extras/producer_rb.html +110 -0
- data/doc/files/extras/server_rb.html +110 -0
- data/doc/files/lib/evented-memcache-client_rb.html +125 -0
- data/doc/files/lib/evented_memcache_client/client_rb.html +120 -0
- data/doc/files/lib/evented_memcache_client/connectable_rb.html +120 -0
- data/doc/files/lib/evented_memcache_client/connection_rb.html +120 -0
- data/doc/files/lib/evented_memcache_client/sender_rb.html +112 -0
- data/doc/files/lib/evented_memcache_client/server_rb.html +120 -0
- data/doc/files/lib/evented_memcache_client/tenacious_rb.html +120 -0
- data/doc/fr_class_index.html +36 -0
- data/doc/fr_file_index.html +38 -0
- data/doc/fr_method_index.html +66 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/extras/consumer.rb +41 -0
- data/extras/producer.rb +22 -0
- data/extras/server.rb +33 -0
- data/lib/evented-memcache-client.rb +37 -0
- data/lib/evented_memcache_client/client.rb +36 -0
- data/lib/evented_memcache_client/connectable.rb +324 -0
- data/lib/evented_memcache_client/connection.rb +73 -0
- data/lib/evented_memcache_client/sender.rb +184 -0
- data/lib/evented_memcache_client/server.rb +118 -0
- data/lib/evented_memcache_client/tenacious.rb +106 -0
- metadata +115 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: EventMachine::Protocols::Memcache::Connection</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">EventMachine::Protocols::Memcache::Connection</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../../files/lib/evented_memcache_client/connection_rb.html">
|
59
|
+
lib/evented_memcache_client/connection.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
EventMachine::Connection
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
Implements a memcache protocol connection.
|
84
|
+
</p>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="method-list">
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
93
|
+
|
94
|
+
<div class="name-list">
|
95
|
+
<a href="#M000040">new</a>
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
<!-- if includes -->
|
103
|
+
<div id="includes">
|
104
|
+
<h3 class="section-bar">Included Modules</h3>
|
105
|
+
|
106
|
+
<div id="includes-list">
|
107
|
+
<span class="include-name"><a href="Connectable.html">Connectable</a></span>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<!-- if method_list -->
|
121
|
+
<div id="methods">
|
122
|
+
<h3 class="section-bar">Public Class methods</h3>
|
123
|
+
|
124
|
+
<div id="method-M000040" class="method-detail">
|
125
|
+
<a name="M000040"></a>
|
126
|
+
|
127
|
+
<div class="method-heading">
|
128
|
+
<a href="#M000040" class="method-signature">
|
129
|
+
<span class="method-name">new</span><span class="method-args">(*args)</span>
|
130
|
+
</a>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="method-description">
|
134
|
+
<p>
|
135
|
+
Create a <a href="Connection.html#M000040">new</a> connection. Args are a
|
136
|
+
hash of callbacks (or a Module — see <a
|
137
|
+
href="Connectable.html#M000004">Connectable#set_handler</a>).
|
138
|
+
</p>
|
139
|
+
<p>
|
140
|
+
Note that when you‘re using <a
|
141
|
+
href="../../../EventMachine.html">EventMachine</a>, you won‘t be
|
142
|
+
calling Connection::new yourself - EM does it for you when a connection is
|
143
|
+
established.
|
144
|
+
</p>
|
145
|
+
<p>
|
146
|
+
Eg:
|
147
|
+
</p>
|
148
|
+
<pre>
|
149
|
+
callbacks = {
|
150
|
+
:open => Proc.new { |conn|
|
151
|
+
conn.set(:key => 'x', :data => Time.now.to_s)
|
152
|
+
},
|
153
|
+
:stored => Proc.new { |conn, data, args|
|
154
|
+
puts "Stored a value"
|
155
|
+
EventMachine::stop
|
156
|
+
},
|
157
|
+
}
|
158
|
+
EventMachine::run {
|
159
|
+
EventMachine::connect('127.0.0.1',
|
160
|
+
12345,
|
161
|
+
EventMachine::Protocols::Memcache::Connection,
|
162
|
+
callbacks)
|
163
|
+
}
|
164
|
+
</pre>
|
165
|
+
<p><a class="source-toggle" href="#"
|
166
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
167
|
+
<div class="method-source-code" id="M000040-source">
|
168
|
+
<pre>
|
169
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/connection.rb, line 64</span>
|
170
|
+
64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
171
|
+
65: <span class="ruby-keyword kw">super</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
172
|
+
66: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">args</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
|
173
|
+
67: <span class="ruby-identifier">set_handler</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
|
174
|
+
68: <span class="ruby-keyword kw">end</span>
|
175
|
+
</pre>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
|
184
|
+
</div>
|
185
|
+
|
186
|
+
|
187
|
+
<div id="validator-badges">
|
188
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
</body>
|
192
|
+
</html>
|
@@ -0,0 +1,389 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: EventMachine::Protocols::Memcache::Sender</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">EventMachine::Protocols::Memcache::Sender</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../../files/lib/evented_memcache_client/sender_rb.html">
|
59
|
+
lib/evented_memcache_client/sender.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
Interface for sending memcache protocol messages like STORE, END, etc. See
|
78
|
+
<a
|
79
|
+
href="http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt">code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt</a>
|
80
|
+
for more details.
|
81
|
+
</p>
|
82
|
+
<p>
|
83
|
+
NB: since several methods are defined dynamically here using define_method,
|
84
|
+
they don‘t show up in the RDoc-generated documentation. Sorry.
|
85
|
+
</p>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
</div>
|
91
|
+
|
92
|
+
<div id="method-list">
|
93
|
+
<h3 class="section-bar">Methods</h3>
|
94
|
+
|
95
|
+
<div class="name-list">
|
96
|
+
<a href="#M000017">book_it</a>
|
97
|
+
<a href="#M000018">cas</a>
|
98
|
+
<a href="#M000021">delete</a>
|
99
|
+
<a href="#M000019">get</a>
|
100
|
+
<a href="#M000020">gets</a>
|
101
|
+
<a href="#M000024">send_to_peer</a>
|
102
|
+
<a href="#M000022">stats</a>
|
103
|
+
<a href="#M000023">value</a>
|
104
|
+
</div>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
<!-- if includes -->
|
111
|
+
|
112
|
+
<div id="section">
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<!-- if method_list -->
|
122
|
+
<div id="methods">
|
123
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
124
|
+
|
125
|
+
<div id="method-M000017" class="method-detail">
|
126
|
+
<a name="M000017"></a>
|
127
|
+
|
128
|
+
<div class="method-heading">
|
129
|
+
<a href="#M000017" class="method-signature">
|
130
|
+
<span class="method-name">book_it</span><span class="method-args">(msg_type)</span>
|
131
|
+
</a>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<div class="method-description">
|
135
|
+
<p>
|
136
|
+
Keeps <a href="Sender.html#M000022">stats</a> on message sends.
|
137
|
+
</p>
|
138
|
+
<p><a class="source-toggle" href="#"
|
139
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
140
|
+
<div class="method-source-code" id="M000017-source">
|
141
|
+
<pre>
|
142
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 39</span>
|
143
|
+
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">book_it</span>(<span class="ruby-identifier">msg_type</span>)
|
144
|
+
40: <span class="ruby-ivar">@snd_stats</span>[<span class="ruby-identifier">msg_type</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
|
145
|
+
41: <span class="ruby-ivar">@snd_stats</span>[<span class="ruby-identifier">msg_type</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
146
|
+
42: <span class="ruby-keyword kw">end</span>
|
147
|
+
</pre>
|
148
|
+
</div>
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div id="method-M000018" class="method-detail">
|
153
|
+
<a name="M000018"></a>
|
154
|
+
|
155
|
+
<div class="method-heading">
|
156
|
+
<a href="#M000018" class="method-signature">
|
157
|
+
<span class="method-name">cas</span><span class="method-args">(*args)</span>
|
158
|
+
</a>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div class="method-description">
|
162
|
+
<p>
|
163
|
+
Send a <a href="Sender.html#M000018">cas</a> request to the memcached
|
164
|
+
server.
|
165
|
+
</p>
|
166
|
+
<p><a class="source-toggle" href="#"
|
167
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
168
|
+
<div class="method-source-code" id="M000018-source">
|
169
|
+
<pre>
|
170
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 64</span>
|
171
|
+
64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cas</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
172
|
+
65: <span class="ruby-identifier">book_it</span>(<span class="ruby-identifier">:cas</span>)
|
173
|
+
66: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:key</span>]
|
174
|
+
67: <span class="ruby-identifier">flags</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:flags</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
175
|
+
68: <span class="ruby-identifier">exptime</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:exptime</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
176
|
+
69: <span class="ruby-identifier">cas_uniq</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:cas_uniq</span>]
|
177
|
+
70: <span class="ruby-identifier">noreply</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:noreply</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
|
178
|
+
71: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:data</span>]
|
179
|
+
72: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':data cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>
|
180
|
+
73: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':key cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>
|
181
|
+
74: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':cas_uniq cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">cas_uniq</span>
|
182
|
+
75: <span class="ruby-identifier">cmd_str</span> = <span class="ruby-node">"cas #{key} #{flags} #{exptime} #{data.length} #{cas_uniq}"</span>
|
183
|
+
76: <span class="ruby-identifier">cmd_str</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" noreply"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">noreply</span>
|
184
|
+
77: <span class="ruby-identifier">send_to_peer</span> <span class="ruby-node">"#{cmd_str}\r\n#{data}\r\n"</span>
|
185
|
+
78: <span class="ruby-keyword kw">end</span>
|
186
|
+
</pre>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
<div id="method-M000021" class="method-detail">
|
192
|
+
<a name="M000021"></a>
|
193
|
+
|
194
|
+
<div class="method-heading">
|
195
|
+
<a href="#M000021" class="method-signature">
|
196
|
+
<span class="method-name">delete</span><span class="method-args">(*args)</span>
|
197
|
+
</a>
|
198
|
+
</div>
|
199
|
+
|
200
|
+
<div class="method-description">
|
201
|
+
<p>
|
202
|
+
Send a <a href="Sender.html#M000021">delete</a> request to the memcached
|
203
|
+
server. <tt>args</tt> is a Hash with a required :key member, and optional
|
204
|
+
:time and :noreply members.
|
205
|
+
</p>
|
206
|
+
<p><a class="source-toggle" href="#"
|
207
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
208
|
+
<div class="method-source-code" id="M000021-source">
|
209
|
+
<pre>
|
210
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 98</span>
|
211
|
+
98: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
212
|
+
99: <span class="ruby-identifier">book_it</span>(<span class="ruby-identifier">:delete</span>)
|
213
|
+
100: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:key</span>]
|
214
|
+
101: <span class="ruby-identifier">time</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:time</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
215
|
+
102: <span class="ruby-identifier">noreply</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:noreply</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
|
216
|
+
103: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':key cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>
|
217
|
+
104: <span class="ruby-identifier">cmd_str</span> = <span class="ruby-node">"delete #{key}"</span>
|
218
|
+
105: <span class="ruby-identifier">cmd_str</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" #{time}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">time</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
219
|
+
106: <span class="ruby-identifier">cmd_str</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" noreply"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">noreply</span>
|
220
|
+
107: <span class="ruby-identifier">send_to_peer</span> <span class="ruby-node">"#{cmd_str}\r\n"</span>
|
221
|
+
108: <span class="ruby-keyword kw">end</span>
|
222
|
+
</pre>
|
223
|
+
</div>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
<div id="method-M000019" class="method-detail">
|
228
|
+
<a name="M000019"></a>
|
229
|
+
|
230
|
+
<div class="method-heading">
|
231
|
+
<a href="#M000019" class="method-signature">
|
232
|
+
<span class="method-name">get</span><span class="method-args">(args)</span>
|
233
|
+
</a>
|
234
|
+
</div>
|
235
|
+
|
236
|
+
<div class="method-description">
|
237
|
+
<p>
|
238
|
+
Send a <a href="Sender.html#M000019">get</a> request to the memcached
|
239
|
+
server. <tt>args</tt> must have a :keys key if it is a hash, otherwise
|
240
|
+
it‘s assumed that it is a single key. Eg., <a
|
241
|
+
href="Sender.html#M000019">get</a>(‘queue’) or <a
|
242
|
+
href="Sender.html#M000019">get</a>(:keys=>[‘queue_a’,
|
243
|
+
‘queue_b’]) or <a
|
244
|
+
href="Sender.html#M000019">get</a>(:key=>’queue’).
|
245
|
+
</p>
|
246
|
+
<p><a class="source-toggle" href="#"
|
247
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
248
|
+
<div class="method-source-code" id="M000019-source">
|
249
|
+
<pre>
|
250
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 84</span>
|
251
|
+
84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">args</span>)
|
252
|
+
85: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:keys</span>)
|
253
|
+
86: <span class="ruby-identifier">keys</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:keys</span>] <span class="ruby-operator">||</span> [<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:key</span>]]
|
254
|
+
87: <span class="ruby-keyword kw">else</span>
|
255
|
+
88: <span class="ruby-identifier">keys</span> = [<span class="ruby-identifier">args</span>]
|
256
|
+
89: <span class="ruby-keyword kw">end</span>
|
257
|
+
90: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'No keys specified.'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">empty?</span>
|
258
|
+
91: <span class="ruby-identifier">send_to_peer</span> <span class="ruby-node">"get #{keys.join(' ')}\r\n"</span>
|
259
|
+
92: <span class="ruby-keyword kw">end</span>
|
260
|
+
</pre>
|
261
|
+
</div>
|
262
|
+
</div>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
<div id="method-M000020" class="method-detail">
|
266
|
+
<a name="M000020"></a>
|
267
|
+
|
268
|
+
<div class="method-heading">
|
269
|
+
<span class="method-name">gets</span><span class="method-args">(args)</span>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p>
|
274
|
+
Alias for <a href="Sender.html#M000019">get</a>
|
275
|
+
</p>
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
<div id="method-M000024" class="method-detail">
|
280
|
+
<a name="M000024"></a>
|
281
|
+
|
282
|
+
<div class="method-heading">
|
283
|
+
<a href="#M000024" class="method-signature">
|
284
|
+
<span class="method-name">send_to_peer</span><span class="method-args">(data)</span>
|
285
|
+
</a>
|
286
|
+
</div>
|
287
|
+
|
288
|
+
<div class="method-description">
|
289
|
+
<p>
|
290
|
+
Send a memcache protocol message contained in the :data argument to the
|
291
|
+
remote endpoint.
|
292
|
+
</p>
|
293
|
+
<p><a class="source-toggle" href="#"
|
294
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
295
|
+
<div class="method-source-code" id="M000024-source">
|
296
|
+
<pre>
|
297
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 176</span>
|
298
|
+
176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_peer</span>(<span class="ruby-identifier">data</span>)
|
299
|
+
177: <span class="ruby-ivar">@msgs_out</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
|
300
|
+
178: <span class="ruby-ivar">@msgs_out</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
301
|
+
179: <span class="ruby-identifier">send_data</span>(<span class="ruby-identifier">data</span>)
|
302
|
+
180: <span class="ruby-keyword kw">end</span>
|
303
|
+
</pre>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
<div id="method-M000022" class="method-detail">
|
309
|
+
<a name="M000022"></a>
|
310
|
+
|
311
|
+
<div class="method-heading">
|
312
|
+
<a href="#M000022" class="method-signature">
|
313
|
+
<span class="method-name">stats</span><span class="method-args">(*args)</span>
|
314
|
+
</a>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
<div class="method-description">
|
318
|
+
<p>
|
319
|
+
Send a <a href="Sender.html#M000022">stats</a> request to the memcached
|
320
|
+
server. <tt>args</tt> is a Array that specifies the specific <a
|
321
|
+
href="Sender.html#M000022">stats</a> command as defined in the memcache
|
322
|
+
protocol.
|
323
|
+
</p>
|
324
|
+
<p><a class="source-toggle" href="#"
|
325
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
326
|
+
<div class="method-source-code" id="M000022-source">
|
327
|
+
<pre>
|
328
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 130</span>
|
329
|
+
130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stats</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
330
|
+
131: <span class="ruby-identifier">book_it</span>(<span class="ruby-identifier">:stats</span>)
|
331
|
+
132: <span class="ruby-identifier">cmd_str</span> = <span class="ruby-node">"stats #{args.join(' ')}"</span>
|
332
|
+
133: <span class="ruby-identifier">send_to_peer</span> <span class="ruby-node">"#{cmd_str}\r\n"</span>
|
333
|
+
134: <span class="ruby-keyword kw">end</span>
|
334
|
+
</pre>
|
335
|
+
</div>
|
336
|
+
</div>
|
337
|
+
</div>
|
338
|
+
|
339
|
+
<div id="method-M000023" class="method-detail">
|
340
|
+
<a name="M000023"></a>
|
341
|
+
|
342
|
+
<div class="method-heading">
|
343
|
+
<a href="#M000023" class="method-signature">
|
344
|
+
<span class="method-name">value</span><span class="method-args">(args)</span>
|
345
|
+
</a>
|
346
|
+
</div>
|
347
|
+
|
348
|
+
<div class="method-description">
|
349
|
+
<p>
|
350
|
+
Send a <a href="Sender.html#M000023">value</a> message to the remote
|
351
|
+
endpoint (client); this is a server-sent message. <tt>args</tt> is a Hash
|
352
|
+
with a required :key member, and optional :flash and :cas_uniq members.
|
353
|
+
Hash must also include a :data member (the payload to be sent).
|
354
|
+
</p>
|
355
|
+
<p><a class="source-toggle" href="#"
|
356
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
357
|
+
<div class="method-source-code" id="M000023-source">
|
358
|
+
<pre>
|
359
|
+
<span class="ruby-comment cmt"># File lib/evented_memcache_client/sender.rb, line 161</span>
|
360
|
+
161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">value</span>(<span class="ruby-identifier">args</span>)
|
361
|
+
162: <span class="ruby-identifier">book_it</span>(<span class="ruby-identifier">:value</span>)
|
362
|
+
163: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:key</span>]
|
363
|
+
164: <span class="ruby-identifier">flags</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:flags</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
364
|
+
165: <span class="ruby-identifier">cas_uniq</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:cas_uniq</span>]
|
365
|
+
166: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:data</span>]
|
366
|
+
167: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':data cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>
|
367
|
+
168: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">':key cannot be nil'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>
|
368
|
+
169: <span class="ruby-identifier">cmd_str</span> = <span class="ruby-node">"VALUE #{key} #{flags} #{data.length}"</span>
|
369
|
+
170: <span class="ruby-identifier">cmd_str</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" #{cas_uniq}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cas_uniq</span>
|
370
|
+
171: <span class="ruby-identifier">send_to_peer</span> <span class="ruby-node">"#{cmd_str}\r\n#{data}\r\n"</span>
|
371
|
+
172: <span class="ruby-keyword kw">end</span>
|
372
|
+
</pre>
|
373
|
+
</div>
|
374
|
+
</div>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
</div>
|
379
|
+
|
380
|
+
|
381
|
+
</div>
|
382
|
+
|
383
|
+
|
384
|
+
<div id="validator-badges">
|
385
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
386
|
+
</div>
|
387
|
+
|
388
|
+
</body>
|
389
|
+
</html>
|