/usr/share/doc/python-pylibmc-doc/html/index.html is in python-pylibmc-doc 1.5.0-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pylibmc - Python client for memcached — pylibmc 1.5.0 documentation</title>
<link rel="stylesheet" href="_static/main.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.5.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="pylibmc 1.5.0 documentation" href="#" />
<link rel="next" title="Change Log" href="changelog.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="changelog.html" title="Change Log"
accesskey="N">next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">pylibmc 1.5.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="body" role="main">
<div class="section" id="pylibmc-python-client-for-memcached">
<h1><code class="xref py py-mod docutils literal"><span class="pre">pylibmc</span></code> - Python client for memcached<a class="headerlink" href="#pylibmc-python-client-for-memcached" title="Permalink to this headline">¶</a></h1>
<p><code class="xref py py-mod docutils literal"><span class="pre">pylibmc</span></code> is a client in Python for <a class="reference external" href="http://memcached.org/">memcached</a>. It is a wrapper around
<a class="reference external" href="http://tangent.org/">TangentOrg</a>‘s <a class="reference external" href="http://libmemcached.org/libMemcached.html">libmemcached</a> library.</p>
<p>The interface is intentionally made as close to <a class="reference external" href="http://www.tummy.com/Community/software/python-memcached/">python-memcached</a>
as possible, so that applications can drop-in replace it.</p>
<p><code class="xref py py-mod docutils literal"><span class="pre">pylibmc</span></code> leverages among other things configurable behaviors, data
pickling, data compression, battle-tested GIL retention, consistent
distribution, and the binary memcached protocol.</p>
<div class="section" id="example-usage">
<h2>Example usage<a class="headerlink" href="#example-usage" title="Permalink to this headline">¶</a></h2>
<p>Create a memcached connection and configure it:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pylibmc</span>
<span class="gp">>>> </span><span class="n">mc</span> <span class="o">=</span> <span class="n">pylibmc</span><span class="o">.</span><span class="n">Client</span><span class="p">([</span><span class="s">"127.0.0.1"</span><span class="p">],</span> <span class="n">binary</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">behaviors</span><span class="o">=</span><span class="p">{</span><span class="s">"tcp_nodelay"</span><span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
<span class="gp">... </span> <span class="s">"ketama"</span><span class="p">:</span> <span class="bp">True</span><span class="p">})</span>
</pre></div>
</div>
<div class="admonition hint">
<p class="first admonition-title">Hint</p>
<p class="last">In earlier versions <code class="docutils literal"><span class="pre">behaviors</span></code> was no keyword
argument, only an attribute. To safe-guard version compatibility use
<code class="docutils literal"><span class="pre">mc.behaviors</span> <span class="pre">=</span> <span class="pre">{...}</span></code></p>
</div>
<p>Basic memcached operations can be accomplished with the mapping interface:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mc</span><span class="p">[</span><span class="s">"some_key"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"Some value"</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="p">[</span><span class="s">"some_key"</span><span class="p">]</span>
<span class="go">'Some value'</span>
<span class="gp">>>> </span><span class="k">del</span> <span class="n">mc</span><span class="p">[</span><span class="s">"some_key"</span><span class="p">]</span>
<span class="gp">>>> </span><span class="s">"some_key"</span> <span class="ow">in</span> <span class="n">mc</span>
<span class="go">False</span>
</pre></div>
</div>
<p>“Classic” style memcached operations allow for more control and clarity:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"some_key"</span><span class="p">,</span> <span class="s">"Some value"</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">value</span> <span class="o">=</span> <span class="n">mc</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"some_key"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">value</span>
<span class="go">'Some value'</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"another_key"</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s">"another_key"</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Automatic pickling of complex Python types:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"complex_plane=awesome"</span><span class="p">,</span> <span class="mi">4</span><span class="o">+</span><span class="mi">3j</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"complex_plane=awesome"</span><span class="p">)</span>
<span class="go">(4+3j)</span>
<span class="gp">>>> </span><span class="kn">import</span> <span class="nn">fractions</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"structured"</span><span class="p">,</span> <span class="p">{</span><span class="s">"a"</span><span class="p">:</span> <span class="p">(</span><span class="s">"b"</span><span class="p">,</span> <span class="s">"c"</span><span class="p">),</span>
<span class="gp">... </span> <span class="s">"a2"</span><span class="p">:</span> <span class="n">fractions</span><span class="o">.</span><span class="n">Fraction</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)})</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"structured"</span><span class="p">)</span>
<span class="go">{'a': ('b', 'c'), 'a2': Fraction(1, 3)}</span>
</pre></div>
</div>
<p>Atomic memcached-side increments and decrements:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"key"</span><span class="p">,</span> <span class="s">"1"</span><span class="p">)</span> <span class="c"># str or int is fine</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s">"key"</span><span class="p">)</span>
<span class="go">2L</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">decr</span><span class="p">(</span><span class="s">"key"</span><span class="p">)</span>
<span class="go">1L</span>
</pre></div>
</div>
<p>Batch operations lessen GIL contention and thus I/O is faster:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">get_multi</span><span class="p">([</span><span class="s">"key"</span><span class="p">,</span> <span class="s">"another_key"</span><span class="p">])</span>
<span class="go">{'key': '1'}</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">set_multi</span><span class="p">({</span><span class="s">"cats"</span><span class="p">:</span> <span class="p">[</span><span class="s">"on acid"</span><span class="p">,</span> <span class="s">"furry"</span><span class="p">],</span> <span class="s">"dogs"</span><span class="p">:</span> <span class="bp">True</span><span class="p">})</span>
<span class="go">[]</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">get_multi</span><span class="p">([</span><span class="s">"cats"</span><span class="p">,</span> <span class="s">"dogs"</span><span class="p">])</span>
<span class="go">{'cats': ['on acid', 'furry'], 'dogs': True}</span>
<span class="gp">>>> </span><span class="n">mc</span><span class="o">.</span><span class="n">delete_multi</span><span class="p">([</span><span class="s">"cats"</span><span class="p">,</span> <span class="s">"dogs"</span><span class="p">,</span> <span class="s">"nonextant"</span><span class="p">])</span>
<span class="go">False</span>
</pre></div>
</div>
</div>
<div class="section" id="further-reading">
<h2>Further Reading<a class="headerlink" href="#further-reading" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Change Log</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html#new-in-version-1-5-0">New in version 1.5.0</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-1-4-0">New in version 1.4.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-1-3-0">New in version 1.3.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-1-2-0">New in version 1.2.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-1-1">New in version 1.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-1-0">New in version 1.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-9">New in version 0.9</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-8">New in version 0.8</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-7">New in version 0.7</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-6">New in version 0.6</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-5">New in version 0.5</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#new-in-version-0-4">New in version 0.4</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="install.html#requirements">Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="install.html#building">Building</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="pooling.html">Pooling</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pooling.html#an-example-with-werkzeug">An example with Werkzeug</a></li>
<li class="toctree-l2"><a class="reference internal" href="pooling.html#fifo-like-pooling">FIFO-like pooling</a></li>
<li class="toctree-l2"><a class="reference internal" href="pooling.html#thread-mapped-pooling">Thread-mapped pooling</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="behaviors.html">Behaviors</a><ul>
<li class="toctree-l2"><a class="reference internal" href="behaviors.html#hashing">Hashing</a></li>
<li class="toctree-l2"><a class="reference internal" href="behaviors.html#id3">Distribution</a></li>
<li class="toctree-l2"><a class="reference internal" href="behaviors.html#failover">Failover</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="misc.html">Miscellaneous information</a><ul>
<li class="toctree-l2"><a class="reference internal" href="misc.html#differences-from-python-memcached">Differences from <code class="docutils literal"><span class="pre">python-memcached</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="misc.html#exceptions">Exceptions</a></li>
<li class="toctree-l2"><a class="reference internal" href="misc.html#compression">Compression</a></li>
<li class="toctree-l2"><a class="reference internal" href="misc.html#threading">Threading</a></li>
<li class="toctree-l2"><a class="reference internal" href="misc.html#python-3-str-vs-bytes-keys">Python 3 <code class="docutils literal"><span class="pre">str</span></code> vs. <code class="docutils literal"><span class="pre">bytes</span></code> keys</a></li>
<li class="toctree-l2"><a class="reference internal" href="misc.html#verify-keys-verify-keys"><cite>verify_keys</cite> ⋁ ¬ <cite>verify_keys</cite></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="coders.html">The List of Honored People</a></li>
</ul>
</div>
</div>
<div class="section" id="links-and-resources">
<h2>Links and resources<a class="headerlink" href="#links-and-resources" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>sendapatch.se: <a class="reference external" href="http://sendapatch.se/">sendapatch.se/</a></li>
<li>GitHub: <a class="reference external" href="http://github.com/lericson/pylibmc">github.com/lericson/pylibmc</a></li>
<li>PyPI: <a class="reference external" href="http://pypi.python.org/pypi/pylibmc">pypi.python.org/pypi/pylibmc</a></li>
<li>libmemcached: <a class="reference external" href="http://libmemcached.org/libMemcached.html">tangent.org/552/libmemcached.html</a></li>
<li>memcached: <a class="reference external" href="http://memcached.org/">memcached.org/</a></li>
<li>BitCoin fund: <a class="reference external" href="bitcoin:12dveKhqiJWCY8zXT4kaHdHELXPeGAUo9h">12dveKhqiJWCY8zXT4kaHdHELXPeGAUo9h</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div><!-- I hate crud -->
<div class="footer" role="contentinfo">
© Copyright 2011, Ludvig Ericson.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.4.
</div>
</body>
</html>
|