4 <html class=
"writer-html5" lang=
"en" >
8 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
10 <title>C/C++ Client Library for memcached
— libmemcached
1.0.99 documentation
</title>
14 <link rel=
"stylesheet" href=
"_static/css/theme.css" type=
"text/css" />
15 <link rel=
"stylesheet" href=
"_static/pygments.css" type=
"text/css" />
24 <script src="_static/js/html5shiv.min.js"></script>
28 <script type=
"text/javascript" id=
"documentation_options" data-url_root=
"./" src=
"_static/documentation_options.js"></script>
29 <script src=
"_static/jquery.js"></script>
30 <script src=
"_static/underscore.js"></script>
31 <script src=
"_static/doctools.js"></script>
32 <script src=
"_static/language_data.js"></script>
34 <script type=
"text/javascript" src=
"_static/js/theme.js"></script>
37 <link rel=
"index" title=
"Index" href=
"genindex.html" />
38 <link rel=
"search" title=
"Search" href=
"search.html" />
39 <link rel=
"copyright" title=
"Copyright" href=
"copyright.html" />
40 <link rel=
"next" title=
"libmemcached API" href=
"libmemcached/index.html" />
41 <link rel=
"prev" title=
"libmemcached Manual" href=
"index.html" />
44 <body class=
"wy-body-for-nav">
47 <div class=
"wy-grid-for-nav">
49 <nav data-toggle=
"wy-nav-shift" class=
"wy-nav-side">
50 <div class=
"wy-side-scroll">
51 <div class=
"wy-side-nav-search" >
55 <a href=
"index.html" class=
"icon icon-home" alt=
"Documentation Home"> libmemcached
72 <form id=
"rtd-search-form" class=
"wy-form" action=
"search.html" method=
"get">
73 <input type=
"text" name=
"q" placeholder=
"Search docs" />
74 <input type=
"hidden" name=
"check_keywords" value=
"yes" />
75 <input type=
"hidden" name=
"area" value=
"default" />
83 <div class=
"wy-menu wy-menu-vertical" data-spy=
"affix" role=
"navigation" aria-label=
"main navigation">
90 <p class=
"caption"><span class=
"caption-text">libmemcached
</span></p>
92 <li class=
"toctree-l1 current"><a class=
"current reference internal" href=
"#">Introduction
</a></li>
93 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libmemcached/index.html">libmemcached API
</a></li>
94 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libmemcached/index_misc.html">Misc
</a></li>
96 <p class=
"caption"><span class=
"caption-text">libmemcachedutil
</span></p>
98 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libmemcachedutil.html">Introduction
</a></li>
99 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libmemcachedutil/index.html">libmemcachedutil API
</a></li>
101 <p class=
"caption"><span class=
"caption-text">libhashkit
</span></p>
103 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libhashkit.html">Introduction
</a></li>
104 <li class=
"toctree-l1"><a class=
"reference internal" href=
"libhashkit/index.html">libhashkit API
</a></li>
106 <p class=
"caption"><span class=
"caption-text">Client Applications
</span></p>
108 <li class=
"toctree-l1"><a class=
"reference internal" href=
"bin/index.html">Client Applications
</a></li>
110 <p class=
"caption"><span class=
"caption-text">Copyright
</span></p>
112 <li class=
"toctree-l1"><a class=
"reference internal" href=
"copyright.html">Copyright
</a></li>
122 <section data-toggle=
"wy-nav-shift" class=
"wy-nav-content-wrap">
125 <nav class=
"wy-nav-top" aria-label=
"top navigation">
127 <i data-toggle=
"wy-nav-top" class=
"fa fa-bars"></i>
128 <a href=
"index.html">libmemcached
</a>
133 <div class=
"wy-nav-content">
135 <div class=
"rst-content">
153 <div role=
"navigation" aria-label=
"breadcrumbs navigation">
155 <ul class=
"wy-breadcrumbs">
157 <li><a href=
"index.html" class=
"icon icon-home"></a> »</li>
159 <li>C/C++ Client Library for memcached
</li>
162 <li class=
"wy-breadcrumbs-aside">
173 <div role=
"main" class=
"document" itemscope=
"itemscope" itemtype=
"http://schema.org/Article">
174 <div itemprop=
"articleBody">
176 <div class=
"section" id=
"c-c-client-library-for-memcached">
177 <h1>C/C++ Client Library for memcached
<a class=
"headerlink" href=
"#c-c-client-library-for-memcached" title=
"Permalink to this headline">¶
</a></h1>
178 <div class=
"section" id=
"synopsis">
179 <h2>SYNOPSIS
<a class=
"headerlink" href=
"#synopsis" title=
"Permalink to this headline">¶
</a></h2>
181 <dt>#include
<libmemcached/memcached.h
></dt><dd><p>Compile and link with -lmemcached
</p>
184 <hr class=
"docutils" />
185 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> is an open source C/C++ client library and tools for the
186 memcached server (
<a class=
"reference external" href=
"http://memcached.org/">http://memcached.org/
</a>). It has been designed to be light on
187 memory usage, thread safe, and provide full access to server side methods.
</p>
188 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> was designed to provide the greatest number of options to use
189 Memcached. Some of the features provided:
</p>
190 <ol class=
"arabic simple">
191 <li><p>Asynchronous and Synchronous Transport Support.
</p></li>
192 <li><p>Consistent Hashing and Distribution.
</p></li>
193 <li><p>Tunable Hashing algorithm to match keys.
</p></li>
194 <li><p>Access to large object support.
</p></li>
195 <li><p>Local replication.
</p></li>
196 <li><p>A complete reference guide and documentation to the API.
</p></li>
197 <li><p>Tools to Manage your Memcached networks.
</p></li>
200 <div class=
"section" id=
"description">
201 <h2>DESCRIPTION
<a class=
"headerlink" href=
"#description" title=
"Permalink to this headline">¶
</a></h2>
202 <p>"Memcached is a high-performance, distributed memory object caching system,
203 generic in nature, but intended for use in speeding up dynamic web applications
204 by alleviating database load.
" <a class=
"reference external" href=
"http://memcached.org/">http://memcached.org/
</a></p>
205 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> is a small, thread-safe client library for the memcached
206 protocol. The code has all been written to allow for both web and embedded
207 usage. It handles the work behind routing individual keys to specific servers
208 specified by the developer (and values are matched based on server order as
209 supplied by the user). It implements a modular and consistent method of object
211 <p>There are multiple implemented routing and hashing methods. See the
212 <a class=
"reference internal" href=
"libmemcached/memcached_behavior.html#_CPPv422memcached_behavior_setP12memcached_st20memcached_behavior_t8uint64_t" title=
"memcached_behavior_set"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_behavior_set()
</span></code></a> manpage for more information.
</p>
213 <p>All operations are performed against a
<a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a> structure. These
214 structures can either be dynamically allocated or statically allocated and then
215 initialized by
<a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv416memcached_createP12memcached_st" title=
"memcached_create"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_create()
</span></code></a>. Functions have been written in order to
216 encapsulate the
<a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a>. It is not recommended that you operate directly
217 against the structure.
</p>
218 <p>Nearly all functions return a
<a class=
"reference internal" href=
"libmemcached/memcached_return_t.html#_CPPv418memcached_return_t" title=
"memcached_return_t"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_return_t
</span></code></a> value. This value can be
219 translated to a printable string with
<a class=
"reference internal" href=
"libmemcached/memcached_strerror.html#_CPPv418memcached_strerrorP12memcached_st18memcached_return_t" title=
"memcached_strerror"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_strerror()
</span></code></a>.
</p>
220 <p>Objects are stored on servers by hashing keys. The hash value maps the key to a
221 particular server. All clients understand how this hashing works, so it is
222 possibly to reliably both push data to a server and retrieve data from a server.
</p>
223 <p>Group keys can be optionally used to group sets of objects with servers.
</p>
224 <p>Namespaces are supported, and can be used to partition caches so that multiple
225 applications can use the same memcached servers.
</p>
226 <p>Some features of the library must be enabled through
<a class=
"reference internal" href=
"libmemcached/memcached_behavior.html#_CPPv422memcached_behavior_setP12memcached_st20memcached_behavior_t8uint64_t" title=
"memcached_behavior_set"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_behavior_set()
</span></code></a>.
</p>
228 <div class=
"section" id=
"threads-and-processes">
229 <h2>THREADS AND PROCESSES
<a class=
"headerlink" href=
"#threads-and-processes" title=
"Permalink to this headline">¶
</a></h2>
230 <p>No global variables are used in this library.
</p>
231 <p><a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a> structures are thread-safe, but when using threads or forked
232 processes it is important to keep one instance of
<a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a> per process or
233 thread. Without creating your own locking structures you can not share a single
234 <a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a>. However, you can call
<a class=
"reference internal" href=
"libmemcached/memcached_quit.html#_CPPv414memcached_quitP12memcached_st" title=
"memcached_quit"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_quit()
</span></code></a> on a
<a class=
"reference internal" href=
"libmemcached/memcached_create.html#_CPPv412memcached_st" title=
"memcached_st"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_st
</span></code></a> and
235 then use the resulting cloned structure.
</p>
237 <div class=
"section" id=
"systemtap">
238 <h2>SYSTEMTAP
<a class=
"headerlink" href=
"#systemtap" title=
"Permalink to this headline">¶
</a></h2>
239 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> can be built to support Systemtap on Linux when enabled at
241 <p>Please see
<em class=
"manpage"><a class=
"manpage reference external" href=
"https://linux.die.net/man/1/stap">stap(
1)
</a></em> and
<em class=
"manpage"><a class=
"manpage reference external" href=
"https://linux.die.net/man/1/dtrace">dtrace(
1)
</a></em> for more information
244 <div class=
"section" id=
"client-programs">
245 <h2>CLIENT PROGRAMS
<a class=
"headerlink" href=
"#client-programs" title=
"Permalink to this headline">¶
</a></h2>
246 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> comes with a few useful client programs:
</p>
248 <li><p><a class=
"reference internal" href=
"bin/memaslap.html"><span class=
"doc">memaslap - Load testing and benchmarking a server
</span></a></p></li>
249 <li><p><a class=
"reference internal" href=
"bin/memcapable.html"><span class=
"doc">memcapable
</span></a></p></li>
250 <li><p><a class=
"reference internal" href=
"bin/memcat.html"><span class=
"doc">memcat
</span></a></p></li>
251 <li><p><a class=
"reference internal" href=
"bin/memcp.html"><span class=
"doc">memcp
</span></a></p></li>
252 <li><p><a class=
"reference internal" href=
"bin/memdump.html"><span class=
"doc">memdump
</span></a></p></li>
253 <li><p><a class=
"reference internal" href=
"bin/memerror.html"><span class=
"doc">memerror
</span></a></p></li>
254 <li><p><a class=
"reference internal" href=
"bin/memexist.html"><span class=
"doc">memexist
</span></a></p></li>
255 <li><p><a class=
"reference internal" href=
"bin/memflush.html"><span class=
"doc">memflush
</span></a></p></li>
256 <li><p><a class=
"reference internal" href=
"bin/memparse.html"><span class=
"doc">memparse
</span></a></p></li>
257 <li><p><a class=
"reference internal" href=
"bin/memping.html"><span class=
"doc">memping
</span></a></p></li>
258 <li><p><a class=
"reference internal" href=
"bin/memrm.html"><span class=
"doc">memrm
</span></a></p></li>
259 <li><p><a class=
"reference internal" href=
"bin/memslap.html"><span class=
"doc">memslap
</span></a></p></li>
260 <li><p><a class=
"reference internal" href=
"bin/memstat.html"><span class=
"doc">memstat
</span></a></p></li>
261 <li><p><a class=
"reference internal" href=
"bin/memtouch.html"><span class=
"doc">memtouch
</span></a></p></li>
264 <div class=
"section" id=
"utility-libraries">
265 <h2>UTILITY LIBRARIES
<a class=
"headerlink" href=
"#utility-libraries" title=
"Permalink to this headline">¶
</a></h2>
267 <li><p><a class=
"reference internal" href=
"libhashkit.html"><span class=
"doc">libhashkit - C/C++ hashing library
</span></a></p></li>
268 <li><p><a class=
"reference internal" href=
"libmemcachedutil.html"><span class=
"doc">libmemcachedutil - C/C++ utilities extending libmemcached
</span></a></p></li>
271 <div class=
"section" id=
"see-also">
272 <h2>SEE ALSO
<a class=
"headerlink" href=
"#see-also" title=
"Permalink to this headline">¶
</a></h2>
274 <li><p><em class=
"manpage"><a class=
"manpage reference external" href=
"https://linux.die.net/man/1/memcached">memcached(
1)
</a></em></p></li>
275 <li><p><a class=
"reference internal" href=
"libmemcached/configuration.html"><span class=
"doc">libmemcached Configuration
</span></a></p></li>
276 <li><p><a class=
"reference internal" href=
"libmemcached/examples.html"><span class=
"doc">libmemcached Examples
</span></a></p></li>
287 <div class=
"rst-footer-buttons" role=
"navigation" aria-label=
"footer navigation">
289 <a href=
"libmemcached/index.html" class=
"btn btn-neutral float-right" title=
"libmemcached API" accesskey=
"n" rel=
"next">Next
<span class=
"fa fa-arrow-circle-right"></span></a>
292 <a href=
"index.html" class=
"btn btn-neutral float-left" title=
"libmemcached Manual" accesskey=
"p" rel=
"prev"><span class=
"fa fa-arrow-circle-left"></span> Previous
</a>
299 <div role=
"contentinfo">
303 © <a href=
"copyright.html">Copyright
</a>
310 Built with
<a href=
"http://sphinx-doc.org/">Sphinx
</a> using a
312 <a href=
"https://github.com/rtfd/sphinx_rtd_theme">theme
</a>
314 provided by
<a href=
"https://readthedocs.org">Read the Docs
</a>.
326 <script type=
"text/javascript">
328 SphinxRtdTheme.Navigation.enable(true);