1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module memcache</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>memcache</strong></big></big> (version 1.48)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/tmp/python-memcached-1.48/memcache.py">/tmp/python-memcached-1.48/memcache.py</a></font></td></tr></table>
<p><tt>client module for memcached (memory cache daemon)<br>
<br>
Overview<br>
========<br>
<br>
See U{the MemCached homepage<<a href="http://www.danga.com/memcached">http://www.danga.com/memcached</a>>} for more about memcached.<br>
<br>
Usage summary<br>
=============<br>
<br>
This should give you a feel for how this module operates::<br>
<br>
import memcache<br>
mc = memcache.<a href="#Client">Client</a>(['127.0.0.1:11211'], debug=0)<br>
<br>
mc.set("some_key", "Some value")<br>
value = mc.get("some_key")<br>
<br>
mc.set("another_key", 3)<br>
mc.delete("another_key")<br>
<br>
mc.set("key", "1") # note that the key used for incr/decr must be a string.<br>
mc.incr("key")<br>
mc.decr("key")<br>
<br>
The standard way to use memcache with a database is like this::<br>
<br>
key = derive_key(obj)<br>
obj = mc.get(key)<br>
if not obj:<br>
obj = backend_api.get(...)<br>
mc.set(key, obj)<br>
<br>
# we now have obj, and future passes through this code<br>
# will use the object from the cache.<br>
<br>
Detailed Documentation<br>
======================<br>
<br>
More detailed documentation is available in the L{<a href="#Client">Client</a>} class.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
<a href="cPickle.html">cPickle</a><br>
</td><td width="25%" valign=top><a href="re.html">re</a><br>
<a href="socket.html">socket</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
<a href="time.html">time</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="thread.html#_local">thread._local</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="memcache.html#Client">Client</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Client">class <strong>Client</strong></a>(<a href="thread.html#_local">thread._local</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object representing a pool of memcache servers.<br>
<br>
See L{memcache} for an overview.<br>
<br>
In all cases where a key is used, the key can be either:<br>
1. A simple hashable type (string, integer, etc.).<br>
2. A tuple of C{(hashvalue, key)}. This is useful if you want to avoid<br>
making this module calculate a hash value. You may prefer, for<br>
example, to keep all of a given user's objects on the same memcache<br>
server, so you could use the user's unique id as the hash value.<br>
<br>
@group Setup: __init__, set_servers, forget_dead_hosts, disconnect_all, debuglog<br>
@group Insertion: set, add, replace, set_multi<br>
@group Retrieval: get, get_multi<br>
@group Integers: incr, decr<br>
@group Removal: delete, delete_multi<br>
@sort: __init__, set_servers, forget_dead_hosts, disconnect_all, debuglog, set, set_multi, add, replace, get, get_multi, incr, decr, delete, delete_multi<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="memcache.html#Client">Client</a></dd>
<dd><a href="thread.html#_local">thread._local</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="Client-__init__"><strong>__init__</strong></a>(self, servers, debug<font color="#909090">=0</font>, pickleProtocol<font color="#909090">=0</font>, pickler<font color="#909090">=<built-in function Pickler></font>, unpickler<font color="#909090">=<built-in function Unpickler></font>, pload<font color="#909090">=None</font>, pid<font color="#909090">=None</font>, server_max_key_length<font color="#909090">=250</font>, server_max_value_length<font color="#909090">=1048576</font>, dead_retry<font color="#909090">=30</font>, socket_timeout<font color="#909090">=3</font>, cache_cas<font color="#909090">=False</font>)</dt><dd><tt>Create a new <a href="#Client">Client</a> object with the given list of servers.<br>
<br>
@param servers: C{servers} is passed to L{set_servers}.<br>
@param debug: whether to display error messages when a server can't be<br>
contacted.<br>
@param pickleProtocol: number to mandate protocol used by (c)Pickle.<br>
@param pickler: optional override of default Pickler to allow subclassing.<br>
@param unpickler: optional override of default Unpickler to allow subclassing.<br>
@param pload: optional persistent_load function to call on pickle loading.<br>
Useful for cPickle since subclassing isn't allowed.<br>
@param pid: optional persistent_id function to call on pickle storing.<br>
Useful for cPickle since subclassing isn't allowed.<br>
@param dead_retry: number of seconds before retrying a blacklisted<br>
server. Default to 30 s.<br>
@param socket_timeout: timeout in seconds for all calls to a server. Defaults<br>
to 3 seconds.<br>
@param cache_cas: (default False) If true, cas operations will be<br>
cached. WARNING: This cache is not expired internally, if you have<br>
a long-running process you will need to expire it manually via<br>
"client.<a href="#Client-reset_cas">reset_cas</a>(), or the cache can grow unlimited.<br>
@param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)<br>
Data that is larger than this will not be sent to the server.<br>
@param server_max_value_length: (default SERVER_MAX_VALUE_LENGTH)<br>
Data that is larger than this will not be sent to the server.</tt></dd></dl>
<dl><dt><a name="Client-add"><strong>add</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Add new key with value.<br>
<br>
Like L{set}, but only stores in memcache if the key doesn't already exist.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-append"><strong>append</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Append the value to the end of the existing key's value.<br>
<br>
Only stores in memcache if key already exists.<br>
Also see L{prepend}.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-cas"><strong>cas</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Sets a key to a given value in the memcache if it hasn't been<br>
altered since last fetched. (See L{gets}).<br>
<br>
The C{key} can optionally be an tuple, with the first element<br>
being the server hash value and the second being the key.<br>
If you want to avoid making this module calculate a hash value.<br>
You may prefer, for example, to keep all of a given user's objects<br>
on the same memcache server, so you could use the user's unique<br>
id as the hash value.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int<br>
@param time: Tells memcached the time which this value should expire,<br>
either as a delta number of seconds, or an absolute unix<br>
time-since-the-epoch value. See the memcached protocol docs section<br>
"Storage Commands" for more info on <exptime>. We default to<br>
0 == cache forever.<br>
@param min_compress_len: The threshold length to kick in<br>
auto-compression of the value using the zlib.<a href="#-compress">compress</a>() routine. If<br>
the value being cached is a string, then the length of the string is<br>
measured, else if the value is an object, then the length of the<br>
pickle result is measured. If the resulting attempt at compression<br>
yeilds a larger string than the input, then it is discarded. For<br>
backwards compatability, this parameter defaults to 0, indicating<br>
don't ever try to compress.</tt></dd></dl>
<dl><dt><a name="Client-check_key"><strong>check_key</strong></a>(self, key, key_extra_len<font color="#909090">=0</font>)</dt><dd><tt>Checks sanity of key. Fails if:<br>
Key length is > SERVER_MAX_KEY_LENGTH (Raises MemcachedKeyLength).<br>
Contains control characters (Raises MemcachedKeyCharacterError).<br>
Is not a string (Raises MemcachedStringEncodingError)<br>
Is an unicode string (Raises MemcachedStringEncodingError)<br>
Is not a string (Raises MemcachedKeyError)<br>
Is None (Raises MemcachedKeyError)</tt></dd></dl>
<dl><dt><a name="Client-debuglog"><strong>debuglog</strong></a>(self, str)</dt></dl>
<dl><dt><a name="Client-decr"><strong>decr</strong></a>(self, key, delta<font color="#909090">=1</font>)</dt><dd><tt>Like L{incr}, but decrements. Unlike L{incr}, underflow is checked and<br>
new values are capped at 0. If server value is 1, a decrement of 2<br>
returns 0, not -1.<br>
<br>
@param delta: Integer amount to decrement by (should be zero or greater).<br>
@return: New value after decrementing.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-delete"><strong>delete</strong></a>(self, key, time<font color="#909090">=0</font>)</dt><dd><tt>Deletes a key from the memcache.<br>
<br>
@return: Nonzero on success.<br>
@param time: number of seconds any subsequent set / update commands<br>
should fail. Defaults to None for no delay.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-delete_multi"><strong>delete_multi</strong></a>(self, keys, time<font color="#909090">=0</font>, key_prefix<font color="#909090">=''</font>)</dt><dd><tt>Delete multiple keys in the memcache doing just one query.<br>
<br>
>>> notset_keys = mc.<a href="#Client-set_multi">set_multi</a>({'key1' : 'val1', 'key2' : 'val2'})<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(['key1', 'key2']) == {'key1' : 'val1', 'key2' : 'val2'}<br>
1<br>
>>> mc.<a href="#Client-delete_multi">delete_multi</a>(['key1', 'key2'])<br>
1<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(['key1', 'key2']) == {}<br>
1<br>
<br>
<br>
This method is recommended over iterated regular L{delete}s as it reduces total latency, since<br>
your app doesn't have to wait for each round-trip of L{delete} before sending<br>
the next one.<br>
<br>
@param keys: An iterable of keys to clear<br>
@param time: number of seconds any subsequent set / update commands should fail. Defaults to 0 for no delay.<br>
@param key_prefix: Optional string to prepend to each key when sending to memcache.<br>
See docs for L{get_multi} and L{set_multi}.<br>
<br>
@return: 1 if no failure in communication with any memcacheds.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-disconnect_all"><strong>disconnect_all</strong></a>(self)</dt></dl>
<dl><dt><a name="Client-flush_all"><strong>flush_all</strong></a>(self)</dt><dd><tt>Expire all data currently in the memcache servers.</tt></dd></dl>
<dl><dt><a name="Client-forget_dead_hosts"><strong>forget_dead_hosts</strong></a>(self)</dt><dd><tt>Reset every host in the pool to an "alive" state.</tt></dd></dl>
<dl><dt><a name="Client-get"><strong>get</strong></a>(self, key)</dt><dd><tt>Retrieves a key from the memcache.<br>
<br>
@return: The value or None.</tt></dd></dl>
<dl><dt><a name="Client-get_multi"><strong>get_multi</strong></a>(self, keys, key_prefix<font color="#909090">=''</font>)</dt><dd><tt>Retrieves multiple keys from the memcache doing just one query.<br>
<br>
>>> success = mc.<a href="#Client-set">set</a>("foo", "bar")<br>
>>> success = mc.<a href="#Client-set">set</a>("baz", 42)<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(["foo", "baz", "foobar"]) == {"foo": "bar", "baz": 42}<br>
1<br>
>>> mc.<a href="#Client-set_multi">set_multi</a>({'k1' : 1, 'k2' : 2}, key_prefix='pfx_') == []<br>
1<br>
<br>
This looks up keys 'pfx_k1', 'pfx_k2', ... . Returned dict will just have unprefixed keys 'k1', 'k2'.<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(['k1', 'k2', 'nonexist'], key_prefix='pfx_') == {'k1' : 1, 'k2' : 2}<br>
1<br>
<br>
get_mult [ and L{set_multi} ] can take str()-ables like ints / longs as keys too. Such as your db pri key fields.<br>
They're rotored through str() before being passed off to memcache, with or without the use of a key_prefix.<br>
In this mode, the key_prefix could be a table name, and the key itself a db primary key number.<br>
<br>
>>> mc.<a href="#Client-set_multi">set_multi</a>({42: 'douglass adams', 46 : 'and 2 just ahead of me'}, key_prefix='numkeys_') == []<br>
1<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>([46, 42], key_prefix='numkeys_') == {42: 'douglass adams', 46 : 'and 2 just ahead of me'}<br>
1<br>
<br>
This method is recommended over regular L{get} as it lowers the number of<br>
total packets flying around your network, reducing total latency, since<br>
your app doesn't have to wait for each round-trip of L{get} before sending<br>
the next one.<br>
<br>
See also L{set_multi}.<br>
<br>
@param keys: An array of keys.<br>
@param key_prefix: A string to prefix each key when we communicate with memcache.<br>
Facilitates pseudo-namespaces within memcache. Returned dictionary keys will not have this prefix.<br>
@return: A dictionary of key/value pairs that were available. If key_prefix was provided, the keys in the retured dictionary will not have it present.</tt></dd></dl>
<dl><dt><a name="Client-get_slabs"><strong>get_slabs</strong></a>(self)</dt></dl>
<dl><dt><a name="Client-get_stats"><strong>get_stats</strong></a>(self, stat_args<font color="#909090">=None</font>)</dt><dd><tt>Get statistics from each of the servers.<br>
<br>
@param stat_args: Additional arguments to pass to the memcache<br>
"stats" command.<br>
<br>
@return: A list of tuples ( server_identifier, stats_dictionary ).<br>
The dictionary contains a number of name/value pairs specifying<br>
the name of the status field and the string value associated with<br>
it. The values are not converted from strings.</tt></dd></dl>
<dl><dt><a name="Client-gets"><strong>gets</strong></a>(self, key)</dt><dd><tt>Retrieves a key from the memcache. Used in conjunction with 'cas'.<br>
<br>
@return: The value or None.</tt></dd></dl>
<dl><dt><a name="Client-incr"><strong>incr</strong></a>(self, key, delta<font color="#909090">=1</font>)</dt><dd><tt>Sends a command to the server to atomically increment the value<br>
for C{key} by C{delta}, or by 1 if C{delta} is unspecified.<br>
Returns None if C{key} doesn't exist on server, otherwise it<br>
returns the new value after incrementing.<br>
<br>
Note that the value for C{key} must already exist in the memcache,<br>
and it must be the string representation of an integer.<br>
<br>
>>> mc.<a href="#Client-set">set</a>("counter", "20") # returns 1, indicating success<br>
1<br>
>>> mc.<a href="#Client-incr">incr</a>("counter")<br>
21<br>
>>> mc.<a href="#Client-incr">incr</a>("counter")<br>
22<br>
<br>
Overflow on server is not checked. Be aware of values approaching<br>
2**32. See L{decr}.<br>
<br>
@param delta: Integer amount to increment by (should be zero or greater).<br>
@return: New value after incrementing.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-prepend"><strong>prepend</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Prepend the value to the beginning of the existing key's value.<br>
<br>
Only stores in memcache if key already exists.<br>
Also see L{append}.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-replace"><strong>replace</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Replace existing key with value.<br>
<br>
Like L{set}, but only stores in memcache if the key already exists.<br>
The opposite of L{add}.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int</tt></dd></dl>
<dl><dt><a name="Client-reset_cas"><strong>reset_cas</strong></a>(self)</dt><dd><tt>Reset the cas cache. This is only used if the <a href="#Client">Client</a>() object<br>
was created with "cache_cas=True". If used, this cache does not<br>
expire internally, so it can grow unbounded if you do not clear it<br>
yourself.</tt></dd></dl>
<dl><dt><a name="Client-set"><strong>set</strong></a>(self, key, val, time<font color="#909090">=0</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Unconditionally sets a key to a given value in the memcache.<br>
<br>
The C{key} can optionally be an tuple, with the first element<br>
being the server hash value and the second being the key.<br>
If you want to avoid making this module calculate a hash value.<br>
You may prefer, for example, to keep all of a given user's objects<br>
on the same memcache server, so you could use the user's unique<br>
id as the hash value.<br>
<br>
@return: Nonzero on success.<br>
@rtype: int<br>
@param time: Tells memcached the time which this value should expire, either<br>
as a delta number of seconds, or an absolute unix time-since-the-epoch<br>
value. See the memcached protocol docs section "Storage Commands"<br>
for more info on <exptime>. We default to 0 == cache forever.<br>
@param min_compress_len: The threshold length to kick in auto-compression<br>
of the value using the zlib.<a href="#-compress">compress</a>() routine. If the value being cached is<br>
a string, then the length of the string is measured, else if the value is an<br>
object, then the length of the pickle result is measured. If the resulting<br>
attempt at compression yeilds a larger string than the input, then it is<br>
discarded. For backwards compatability, this parameter defaults to 0,<br>
indicating don't ever try to compress.</tt></dd></dl>
<dl><dt><a name="Client-set_multi"><strong>set_multi</strong></a>(self, mapping, time<font color="#909090">=0</font>, key_prefix<font color="#909090">=''</font>, min_compress_len<font color="#909090">=0</font>)</dt><dd><tt>Sets multiple keys in the memcache doing just one query.<br>
<br>
>>> notset_keys = mc.<a href="#Client-set_multi">set_multi</a>({'key1' : 'val1', 'key2' : 'val2'})<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(['key1', 'key2']) == {'key1' : 'val1', 'key2' : 'val2'}<br>
1<br>
<br>
<br>
This method is recommended over regular L{set} as it lowers the number of<br>
total packets flying around your network, reducing total latency, since<br>
your app doesn't have to wait for each round-trip of L{set} before sending<br>
the next one.<br>
<br>
@param mapping: A dict of key/value pairs to set.<br>
@param time: Tells memcached the time which this value should expire, either<br>
as a delta number of seconds, or an absolute unix time-since-the-epoch<br>
value. See the memcached protocol docs section "Storage Commands"<br>
for more info on <exptime>. We default to 0 == cache forever.<br>
@param key_prefix: Optional string to prepend to each key when sending to memcache. Allows you to efficiently stuff these keys into a pseudo-namespace in memcache:<br>
>>> notset_keys = mc.<a href="#Client-set_multi">set_multi</a>({'key1' : 'val1', 'key2' : 'val2'}, key_prefix='subspace_')<br>
>>> len(notset_keys) == 0<br>
True<br>
>>> mc.<a href="#Client-get_multi">get_multi</a>(['subspace_key1', 'subspace_key2']) == {'subspace_key1' : 'val1', 'subspace_key2' : 'val2'}<br>
True<br>
<br>
Causes key 'subspace_key1' and 'subspace_key2' to be set. Useful in conjunction with a higher-level layer which applies namespaces to data in memcache.<br>
In this case, the return result would be the list of notset original keys, prefix not applied.<br>
<br>
@param min_compress_len: The threshold length to kick in auto-compression<br>
of the value using the zlib.<a href="#-compress">compress</a>() routine. If the value being cached is<br>
a string, then the length of the string is measured, else if the value is an<br>
object, then the length of the pickle result is measured. If the resulting<br>
attempt at compression yeilds a larger string than the input, then it is<br>
discarded. For backwards compatability, this parameter defaults to 0,<br>
indicating don't ever try to compress.<br>
@return: List of keys which failed to be stored [ memcache out of memory, etc. ].<br>
@rtype: list</tt></dd></dl>
<dl><dt><a name="Client-set_servers"><strong>set_servers</strong></a>(self, servers)</dt><dd><tt>Set the pool of servers used by this client.<br>
<br>
@param servers: an array of servers.<br>
Servers can be passed in two forms:<br>
1. Strings of the form C{"host:port"}, which implies a default weight of 1.<br>
2. Tuples of the form C{("host:port", weight)}, where C{weight} is<br>
an integer weight value.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>MemcachedKeyCharacterError</strong> = <class 'memcache.MemcachedKeyCharacterError'></dl>
<dl><dt><strong>MemcachedKeyError</strong> = <class 'memcache.MemcachedKeyError'></dl>
<dl><dt><strong>MemcachedKeyLengthError</strong> = <class 'memcache.MemcachedKeyLengthError'></dl>
<dl><dt><strong>MemcachedKeyNoneError</strong> = <class 'memcache.MemcachedKeyNoneError'></dl>
<dl><dt><strong>MemcachedKeyTypeError</strong> = <class 'memcache.MemcachedKeyTypeError'></dl>
<dl><dt><strong>MemcachedStringEncodingError</strong> = <class 'memcache.MemcachedStringEncodingError'></dl>
<hr>
Methods inherited from <a href="thread.html#_local">thread._local</a>:<br>
<dl><dt><a name="Client-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Client-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
<dl><dt><a name="Client-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#Client-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="Client-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Client-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
<hr>
Data and other attributes inherited from <a href="thread.html#_local">thread._local</a>:<br>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#Client-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-StringIO"><strong>StringIO</strong></a>(...)</dt><dd><tt><a href="#-StringIO">StringIO</a>([s]) -- Return a StringIO-like stream for reading or writing</tt></dd></dl>
<dl><dt><a name="-cmemcache_hash"><strong>cmemcache_hash</strong></a>(key)</dt></dl>
<dl><dt><a name="-compress"><strong>compress</strong></a>(...)</dt><dd><tt><a href="#-compress">compress</a>(string[, level]) -- Returned compressed string.<br>
<br>
Optional arg level is the compression level, in 1-9.</tt></dd></dl>
<dl><dt><a name="-crc32"><strong>crc32</strong></a>(...)</dt><dd><tt>(data, oldcrc = 0) -> newcrc. Compute CRC-32 incrementally</tt></dd></dl>
<dl><dt><a name="-decompress"><strong>decompress</strong></a>(...)</dt><dd><tt><a href="#-decompress">decompress</a>(string[, wbits[, bufsize]]) -- Return decompressed string.<br>
<br>
Optional arg wbits is the window buffer size. Optional arg bufsize is<br>
the initial output buffer size.</tt></dd></dl>
<dl><dt><a name="-serverHashFunction"><strong>serverHashFunction</strong></a> = cmemcache_hash(key)</dt></dl>
<dl><dt><a name="-useOldServerHashFunction"><strong>useOldServerHashFunction</strong></a>()</dt><dd><tt>Use the old python-memcache server hash function.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>SERVER_MAX_KEY_LENGTH</strong> = 250<br>
<strong>SERVER_MAX_VALUE_LENGTH</strong> = 1048576<br>
<strong>__author__</strong> = 'Sean Reifschneider <jafo-memcached@tummy.com>'<br>
<strong>__copyright__</strong> = 'Copyright (C) 2003 Danga Interactive'<br>
<strong>__license__</strong> = 'Python Software Foundation License'<br>
<strong>__version__</strong> = '1.48'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Sean Reifschneider <jafo-memcached@tummy.com></td></tr></table>
</body></html>
|