configure
docs/*.[13]
docs/*.html
+docs/conf.py
docs/doctest/
docs/doctrees/
docs/html/
+0.50
+
* Updates to C++ interface
* Custom free allocators need to now check for value before calling free.
+ * memcached_fetch_result() now uses the internal result when available (about 25 to 50% faster).
+
0.49 Thu Apr 14 08:43:37 PDT 2011
* Fix calls to auto methods so that if value is not passed in nothing bad happens.
* New parser calls for generating memcached_st objects.
include win32/include.am
include docs/include.am
+docs: html man
+
TESTS += ${check_PROGRAMS}
-EXTRA_DIST+= ${man_MANS}
+EXTRA_DIST+= ${man_MANS}
fedora:
- rm -f ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm
- rm -f ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm
- cp libmemcached-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
- rpmbuild -ba support/libmemcached.spec
- cp ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm .
- cp ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm .
+ @rm -f ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm
+ @rm -f ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm
+ @cp libmemcached-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
+ @rpmbuild -ba support/libmemcached.spec
+ @cp ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm .
+ @cp ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm .
generic:
- rm -f ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm
- rm -f ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm
- cp libmemcached-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
- rpmbuild -ba support/libmemcached.spec
- cp ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm .
- cp ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm .
+ @rm -f ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm
+ @rm -f ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm
+ @cp libmemcached-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
+ @rpmbuild -ba support/libmemcached.spec
+ @cp ~/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm .
+ @cp ~/rpmbuild/RPMS/x86_64/libmemcached-devel-$(VERSION)*.rpm .
+ @cp ~/rpmbuild/RPMS/x86_64/libmemcached-debuginfo-$(VERSION)*.rpm .
+ @cp ~/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm .
+
+rpm: man distcheck generic
-rpm: all man dist generic fedora
+release: rpm
+ @rpm --addsign libmemcached-$(VERSION)*.rpm .
+ @rpm --checksig libmemcached-$(VERSION)*.rpm .
+ @rpm --addsign libmemcached-devel-$(VERSION)*.rpm .
+ @rpm --checksig libmemcached-devel-$(VERSION)*.rpm .
+ @rpm --addsign libmemcached-debuginfo-$(VERSION)*.rpm .
+ @rpm --checksig libmemcached-debuginfo-$(VERSION)*.rpm .
merge-clean:
- find ./ | $(GREP) \.gcda | xargs rm -f
- find ./ | $(GREP) \.gcno | xargs rm -f
- find ./ | $(GREP) \.gz | xargs rm -f
- find ./ | $(GREP) \.orig | xargs rm -f
- find ./ | $(GREP) \.rej | xargs rm -f
- find ./ | $(GREP) \.rpm | xargs rm -f
- find ./ | $(GREP) \~$$ | xargs rm -f
- bzr unknowns
+ @find ./ | $(GREP) \.gcda | xargs rm -f
+ @find ./ | $(GREP) \.gcno | xargs rm -f
+ @find ./ | $(GREP) \.gz | xargs rm -f
+ @find ./ | $(GREP) \.orig | xargs rm -f
+ @find ./ | $(GREP) \.rej | xargs rm -f
+ @find ./ | $(GREP) \.rpm | xargs rm -f
+ @find ./ | $(GREP) \~$$ | xargs rm -f
+ @echo "Files that need to be either removed or checked in:"
+ @bzr unknowns
clean-local:
-rm -rf docs/_build docs/doctrees
@echo "Make sure ./configure was run with '--enable-coverage'"
@echo "------------------------------------------------------"
@echo
- cd libmemcached && lcov --capture --directory . --base-directory .. --output-file lcov.out
- genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out
+ @cd libmemcached && lcov --capture --directory . --base-directory .. --output-file lcov.out
+ @genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out
lcov-clean: clean
- rm -rf lcov */lcov.out
- find . -name '*.gcno' | xargs rm -f
- find . -name '*.gcda' | xargs rm -f
+ @rm -rf lcov */lcov.out
+ @find . -name '*.gcno' | xargs rm -f
+ @find . -name '*.gcda' | xargs rm -f
DISTCLEANFILES+= config/top.h
memstat - Dump the stats of your servers to standard output
memslap - Load generation utility (benchmark!)
-The utilities are beta quality at this point. The library is in production
-in many locations (upwards to 1000+ nodes).
+The library is in production in many locations (upwards to 1000+ nodes).
+
+The project has information here: http://libmemcached.org/
+
+Documentation can be found here: http://docs.libmemcached.org/
Want to contribute? If you write more then three good patches, then I will
just ask you to commit directly to the tree. I am happy to have additional
If you are looking for answers to your questions please check out the
mailing list at:
-http://lists.tangent.org/
+http://lists.libmemcached.org/
Subscription information for the libmemcached mailing list can be found there.
+Please report bugs here:
+https://bugs.launchpad.net/libmemcached/
+
+You can purchase support from:
+http://datadifferential.com/
+
+
Cheers,
-Brian Aker
Seattle, WA.
cmd->plain.message.header.request.bodylen=
ntohl(cmd->plain.message.header.request.bodylen);
cmd->plain.message.header.request.cas=
- ntohll(cmd->plain.message.header.request.cas);
+ memcached_ntohll(cmd->plain.message.header.request.cas);
execute(resend_packet(cmd));
return TEST_PASS;
rsp->plain.message.header.response.bodylen=
ntohl(rsp->plain.message.header.response.bodylen);
rsp->plain.message.header.response.cas=
- ntohll(rsp->plain.message.header.response.cas);
+ memcached_ntohll(rsp->plain.message.header.response.cas);
size_t bodysz= rsp->plain.message.header.response.bodylen;
if (bodysz > 0)
cmd->incr.message.header.request.extlen= 20;
cmd->incr.message.header.request.bodylen= (uint32_t)(keylen + 20);
cmd->incr.message.header.request.opaque= 0xdeadbeef;
- cmd->incr.message.body.delta= htonll(delta);
- cmd->incr.message.body.initial= htonll(initial);
+ cmd->incr.message.body.delta= memcached_htonll(delta);
+ cmd->incr.message.body.initial= memcached_htonll(initial);
cmd->incr.message.body.expiration= htonl(exptime);
off_t key_offset= sizeof (protocol_binary_request_no_extras) + 20;
}
/* try to set with the correct CAS value */
- cmd.plain.message.header.request.cas=
- htonll(rsp.plain.message.header.response.cas);
+ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas);
execute(resend_packet(&cmd));
if (cc == PROTOCOL_BINARY_CMD_SET)
{
execute(test_binary_noop());
/* try to set with an incorrect CAS value */
- cmd.plain.message.header.request.cas=
- htonll(rsp.plain.message.header.response.cas - 1);
+ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas - 1);
execute(resend_packet(&cmd));
execute(send_binary_noop());
execute(recv_packet(&rsp));
}
/* verify that replace with CAS value works! */
- cmd.plain.message.header.request.cas=
- htonll(rsp.plain.message.header.response.cas);
+ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas);
execute(resend_packet(&cmd));
if (cc == PROTOCOL_BINARY_CMD_REPLACE)
execute(test_binary_noop());
/* try to set with an incorrect CAS value */
- cmd.plain.message.header.request.cas=
- htonll(rsp.plain.message.header.response.cas - 1);
+ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas - 1);
execute(resend_packet(&cmd));
execute(send_binary_noop());
execute(recv_packet(&rsp));
{
execute(recv_packet(&rsp));
verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS));
- verify(ntohll(rsp.incr.message.body.value) == ii);
+ verify(memcached_ntohll(rsp.incr.message.body.value) == ii);
}
else
execute(test_binary_noop());
{
execute(recv_packet(&rsp));
verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS));
- verify(ntohll(rsp.decr.message.body.value) == (uint64_t)ii);
+ verify(memcached_ntohll(rsp.decr.message.body.value) == (uint64_t)ii);
}
else
execute(test_binary_noop());
{
execute(recv_packet(&rsp));
verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS));
- verify(ntohll(rsp.decr.message.body.value) == 0);
+ verify(memcached_ntohll(rsp.decr.message.body.value) == 0);
}
else
{
{
gettimeofday(&curr_time, NULL);
time_diff= ms_time_diff(&ms_thread->startup_time, &curr_time);
- tps=
- (int64_t)((task->get_opt
- + task->set_opt) / ((uint64_t)time_diff / 1000000));
+ tps= (int64_t)(((task->get_opt + task->set_opt) / (uint64_t)time_diff) * 1000000);
/* current throughput is greater than expected throughput */
if (tps > ms_thread->thread_ctx->tps_perconn)
AC_CONFIG_FILES([
Makefile
+ docs/conf.py
libhashkit/configure.h
libmemcached/configure.h
support/libmemcached.pc
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# libmemcached documentation build configuration file, created by
+# sphinx-quickstart on Sun Mar 6 12:05:53 2011.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+extensions = ['sphinxcontrib.googleanalytics']
+
+# Google
+googleanalytics_id = 'UA-15307604-2'
+googleanalytics_enabled = 'True'
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'libmemcached'
+copyright = u'2011, Brian Aker DataDifferential, http://datadifferential.com/'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@VERSION@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'libmemcacheddoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'libmemcached.tex', u'libmemcached Documentation',
+ u'Brian Aker', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('hashkit_create', 'hashkit_clone', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_create', 'hashkit_create', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_create', 'hashkit_free', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_create', 'hashkit_is_allocated', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_crc32', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_fnv1_32', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_fnv1_64', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_fnv1a_32', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_fnv1a_64', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_functions', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_hsieh', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_jenkins', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_md5', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_functions', 'hashkit_murmur', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('hashkit_value', 'hashkit_value', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('libhashkit', 'libhashkit', u'libhashkit Documentation', [u'Brian Aker'], 3),
+ ('libmemcached', 'libmemcached', u'Introducing the C Client Library for memcached', [u'Brian Aker'], 3),
+ ('libmemcached_configuration', 'libmemcached_check_configuration', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('libmemcached_configuration', 'libmemcached_configuration', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('libmemcached_configuration', 'memcached', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('libmemcached_examples', 'libmemcached_examples', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('libmemcachedutil', 'libmemcachedutil', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memaslap', 'memaslap', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcached_analyze', 'memcached_analyze', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_append', 'memcached_append', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3),
+ ('memcached_append', 'memcached_append_by_key', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3),
+ ('memcached_append', 'memcached_prepend', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3),
+ ('memcached_append', 'memcached_prepend_by_key', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3),
+ ('memcached_auto', 'memcached_auto', u'Incrementing and Decrementing Values', [u'Brian Aker'], 3),
+ ('memcached_auto', 'memcached_decrement', u'Incrementing and Decrementing Values', [u'Brian Aker'], 3),
+ ('memcached_auto', 'memcached_decrement_with_initial', u'Incrementing and Decrementing Values', [u'Brian Aker'], 3),
+ ('memcached_auto', 'memcached_increment', u'Incrementing and Decrementing Values', [u'Brian Aker'], 3),
+ ('memcached_auto', 'memcached_increment_with_initial', u'Incrementing and Decrementing Values', [u'Brian Aker'], 3),
+ ('memcached_behavior', 'memcached_behavior', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_behavior', 'memcached_behavior_get', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_behavior', 'memcached_behavior_set', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_callback', 'memcached_callback', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_callback', 'memcached_callback_get', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_callback', 'memcached_callback_set', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_cas', 'memcached_cas', u'Working with data on the server in an atomic fashion', [u'Brian Aker'], 3),
+ ('memcached_cas', 'memcached_cas_by_key', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_create', 'memcached_clone', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_create', 'memcached_create', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_create', 'memcached_free', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_create', 'memcached_servers_reset', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_delete', 'memcached_delete', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_delete', 'memcached_delete_by_key', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_dump', 'memcached_dump', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_flush', 'memcached_flush', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_flush_buffers', 'memcached_flush_buffers', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_generate_hash_value', 'memcached_generate_hash', u'Generating hash values directly', [u'Brian Aker'], 3),
+ ('memcached_generate_hash_value', 'memcached_generate_hash_value', u'Generating hash values directly', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_fetch', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_fetch_execute', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_fetch_result', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_get', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_get_by_key', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_mget', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_mget_by_key', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_mget_execute', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_get', 'memcached_mget_execute_by_key', u'Retrieving data from the server', [u'Brian Aker'], 3),
+ ('memcached_memory_allocators', 'memcached_get_memory_allocators', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_memory_allocators', 'memcached_memory_allocators', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_memory_allocators', 'memcached_set_memory_allocators', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_memory_allocators', 'memcached_set_memory_allocators_context', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_behavior_get', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_behavior_set', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_create', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_destroy', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_pop', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_push', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_push', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_pool', 'memcached_pool_st', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_quit', 'memcached_quit', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_cas', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_create', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_flags', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_free', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_key_length', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_key_value', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_length', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_st', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_result_st', 'memcached_result_value', u'Working with result sets', [u'Brian Aker'], 3),
+ ('memcached_sasl', 'memcached_destroy_sasl_auth_data', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_sasl', 'memcached_get_sasl_callbacks', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_sasl', 'memcached_sasl', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_sasl', 'memcached_sasl_set_auth_data', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_sasl', 'memcached_set_sasl_callbacks', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_server_st', 'memcached_server_list_append', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_server_st', 'memcached_server_list_count', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_server_st', 'memcached_server_list_free', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_server_st', 'memcached_servers_parse', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_add', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_add_unix_socket', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_count', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_cursor', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_list', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_push', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_server_st', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_servers', 'memcached_servers', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_add', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_add_by_key', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_replace', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_replace_by_key', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_set', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_set', 'memcached_set_by_key', u'Storing and Replacing Data', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stat', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stat_execute', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stat_get_keys', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stat_get_value', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stat_servername', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_stats', 'memcached_stats', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_strerror', 'memcached_strerror', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_user_data', 'memcached_get_user_data', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_user_data', 'memcached_set_user_data', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_user_data', 'memcached_user_data', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_verbosity', 'memcached_verbosity', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_version', 'memcached_lib_version', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcached_version', 'memcached_version', u'libmemcached Documentation', [u'Brian Aker'], 3),
+ ('memcapable', 'memcapable', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcapable', 'memcapable', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcat', 'memcat', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcat', 'memcat', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcp', 'memcp', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memcp', 'memcp', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memdump', 'memdump', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memdump', 'memdump', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memerror', 'memerror', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memerror', 'memerror', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memflush', 'memflush', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memrm', 'memrm', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memslap', 'memslap', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('memstat', 'memstat', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ]
# included from Top Level Makefile.am
# All paths should be given relative to the root
-EXTRA_DIST+= \
- docs/conf.py
-
# Makefile for Sphinx documentation
#
-SPHINXOPTS = ${SPHINX_WARNINGS} -D release=${PANDORA_RELEASE_VERSION}
+SPHINXOPTS = ${SPHINX_WARNINGS}
PAPER =
SPHINX_BUILDDIR = ${top_builddir}/docs
PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(SPHINX_BUILDDIR)/doctest/output.txt."
+
endif
-.TH "HASHKIT_CLONE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_CLONE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_clone \- libhashkit Documentation
.
-.TH "HASHKIT_CRC32" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_CRC32" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_crc32 \- libhashkit Documentation
.
-.TH "HASHKIT_CREATE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_CREATE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_create \- libhashkit Documentation
.
-.TH "HASHKIT_FNV1_32" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FNV1_32" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_fnv1_32 \- libhashkit Documentation
.
-.TH "HASHKIT_FNV1_64" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FNV1_64" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_fnv1_64 \- libhashkit Documentation
.
-.TH "HASHKIT_FNV1A_32" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FNV1A_32" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_fnv1a_32 \- libhashkit Documentation
.
-.TH "HASHKIT_FNV1A_64" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FNV1A_64" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_fnv1a_64 \- libhashkit Documentation
.
-.TH "HASHKIT_FREE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FREE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_free \- libhashkit Documentation
.
-.TH "HASHKIT_FUNCTIONS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_FUNCTIONS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_functions \- libhashkit Documentation
.
-.TH "HASHKIT_HSIEH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_HSIEH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_hsieh \- libhashkit Documentation
.
-.TH "HASHKIT_IS_ALLOCATED" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_IS_ALLOCATED" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_is_allocated \- libhashkit Documentation
.
-.TH "HASHKIT_JENKINS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_JENKINS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_jenkins \- libhashkit Documentation
.
-.TH "HASHKIT_MD5" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_MD5" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_md5 \- libhashkit Documentation
.
-.TH "HASHKIT_MURMUR" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_MURMUR" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_murmur \- libhashkit Documentation
.
-.TH "HASHKIT_VALUE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "HASHKIT_VALUE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
hashkit_value \- libhashkit Documentation
.
-.TH "LIBHASHKIT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBHASHKIT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libhashkit \- libhashkit Documentation
.
-.TH "LIBMEMCACHED" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBMEMCACHED" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libmemcached \- Introducing the C Client Library for memcached
.
-.TH "LIBMEMCACHED_CHECK_CONFIGURATION" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBMEMCACHED_CHECK_CONFIGURATION" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libmemcached_check_configuration \- libmemcached Documentation
.
-.TH "LIBMEMCACHED_CONFIGURATION" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBMEMCACHED_CONFIGURATION" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libmemcached_configuration \- libmemcached Documentation
.
-.TH "LIBMEMCACHED_EXAMPLES" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBMEMCACHED_EXAMPLES" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libmemcached_examples \- libmemcached Documentation
.
-.TH "LIBMEMCACHEDUTIL" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "LIBMEMCACHEDUTIL" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
libmemcachedutil \- libmemcached Documentation
.
-.TH "MEMASLAP" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMASLAP" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memaslap \- libmemcached Documentation
.
-.TH "MEMCACHED" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached \- libmemcached Documentation
.
-.TH "MEMCACHED_ADD" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_ADD" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_add \- Storing and Replacing Data
.
-.TH "MEMCACHED_ADD_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_ADD_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_add_by_key \- Storing and Replacing Data
.
-.TH "MEMCACHED_ANALYZE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_ANALYZE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_analyze \- libmemcached Documentation
.
-.TH "MEMCACHED_APPEND" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_APPEND" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_append \- Appending to or Prepending to data on the server
.
-.TH "MEMCACHED_APPEND_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_APPEND_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_append_by_key \- Appending to or Prepending to data on the server
.
-.TH "MEMCACHED_AUTO" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_AUTO" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_auto \- Incrementing and Decrementing Values
.
-.TH "MEMCACHED_BEHAVIOR" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_BEHAVIOR" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_behavior \- libmemcached Documentation
.
-.TH "MEMCACHED_BEHAVIOR_GET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_BEHAVIOR_GET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_behavior_get \- libmemcached Documentation
.
-.TH "MEMCACHED_BEHAVIOR_SET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_BEHAVIOR_SET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_behavior_set \- libmemcached Documentation
.
-.TH "MEMCACHED_CALLBACK" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CALLBACK" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_callback \- libmemcached Documentation
.
-.TH "MEMCACHED_CALLBACK_GET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CALLBACK_GET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_callback_get \- libmemcached Documentation
.
-.TH "MEMCACHED_CALLBACK_SET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CALLBACK_SET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_callback_set \- libmemcached Documentation
.
-.TH "MEMCACHED_CAS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CAS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_cas \- Working with data on the server in an atomic fashion
.
-.TH "MEMCACHED_CAS_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CAS_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_cas_by_key \- Storing and Replacing Data
.
-.TH "MEMCACHED_CLONE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CLONE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_clone \- libmemcached Documentation
.
-.TH "MEMCACHED_CREATE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_CREATE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_create \- libmemcached Documentation
.
-.TH "MEMCACHED_DECREMENT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DECREMENT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_decrement \- Incrementing and Decrementing Values
.
-.TH "MEMCACHED_DECREMENT_WITH_INITIAL" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DECREMENT_WITH_INITIAL" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_decrement_with_initial \- Incrementing and Decrementing Values
.
-.TH "MEMCACHED_DELETE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DELETE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_delete \- libmemcached Documentation
.
-.TH "MEMCACHED_DELETE_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DELETE_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_delete_by_key \- libmemcached Documentation
.
-.TH "MEMCACHED_DESTROY_SASL_AUTH_DATA" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DESTROY_SASL_AUTH_DATA" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_destroy_sasl_auth_data \- libmemcached Documentation
.
-.TH "MEMCACHED_DUMP" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_DUMP" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_dump \- libmemcached Documentation
.
-.TH "MEMCACHED_FETCH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FETCH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_fetch \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_FETCH_EXECUTE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FETCH_EXECUTE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_fetch_execute \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_FETCH_RESULT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FETCH_RESULT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_fetch_result \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_FLUSH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FLUSH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_flush \- libmemcached Documentation
.
-.TH "MEMCACHED_FLUSH_BUFFERS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FLUSH_BUFFERS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_flush_buffers \- libmemcached Documentation
.
-.TH "MEMCACHED_FREE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_FREE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_free \- libmemcached Documentation
.
-.TH "MEMCACHED_GENERATE_HASH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GENERATE_HASH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_generate_hash \- Generating hash values directly
.
-.TH "MEMCACHED_GENERATE_HASH_VALUE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GENERATE_HASH_VALUE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_generate_hash_value \- Generating hash values directly
.
-.TH "MEMCACHED_GET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_get \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_GET_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GET_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_get_by_key \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_GET_MEMORY_ALLOCATORS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GET_MEMORY_ALLOCATORS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_get_memory_allocators \- libmemcached Documentation
.
-.TH "MEMCACHED_GET_SASL_CALLBACKS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GET_SASL_CALLBACKS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_get_sasl_callbacks \- libmemcached Documentation
.
-.TH "MEMCACHED_GET_USER_DATA" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_GET_USER_DATA" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_get_user_data \- libmemcached Documentation
.
-.TH "MEMCACHED_INCREMENT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_INCREMENT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_increment \- Incrementing and Decrementing Values
.
-.TH "MEMCACHED_INCREMENT_WITH_INITIAL" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_INCREMENT_WITH_INITIAL" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_increment_with_initial \- Incrementing and Decrementing Values
.
-.TH "MEMCACHED_LIB_VERSION" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_LIB_VERSION" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_lib_version \- libmemcached Documentation
.
-.TH "MEMCACHED_MEMORY_ALLOCATORS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_MEMORY_ALLOCATORS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_memory_allocators \- libmemcached Documentation
.
-.TH "MEMCACHED_MGET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_MGET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_mget \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_MGET_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_MGET_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_mget_by_key \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_MGET_EXECUTE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_MGET_EXECUTE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_mget_execute \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_MGET_EXECUTE_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_MGET_EXECUTE_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_mget_execute_by_key \- Retrieving data from the server
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
+returned by the *error value when all objects that have been found are
+returned. The final value upon \fBMEMCACHED_END\fP is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
.sp
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
.sp
+\fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
+all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
+keys at all were found.
+.sp
+\fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
+to \fBMEMCACHED_END\fP upon successful conclusion.
+\fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
+.sp
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
-.TH "MEMCACHED_POOL" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_BEHAVIOR_GET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_BEHAVIOR_GET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_behavior_get \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_BEHAVIOR_SET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_BEHAVIOR_SET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_behavior_set \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_CREATE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_CREATE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_create \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_DESTROY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_DESTROY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_destroy \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_POP" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_POP" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_pop \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_PUSH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_PUSH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_push \- libmemcached Documentation
.
-.TH "MEMCACHED_POOL_ST" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_POOL_ST" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_pool_st \- libmemcached Documentation
.
-.TH "MEMCACHED_PREPEND" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_PREPEND" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_prepend \- Appending to or Prepending to data on the server
.
-.TH "MEMCACHED_PREPEND_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_PREPEND_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_prepend_by_key \- Appending to or Prepending to data on the server
.
-.TH "MEMCACHED_QUIT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_QUIT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_quit \- libmemcached Documentation
.
-.TH "MEMCACHED_REPLACE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_REPLACE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_replace \- Storing and Replacing Data
.
-.TH "MEMCACHED_REPLACE_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_REPLACE_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_replace_by_key \- Storing and Replacing Data
.
-.TH "MEMCACHED_RESULT_CAS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_CAS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_cas \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_CREATE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_CREATE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_create \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_FLAGS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_FLAGS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_flags \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_FREE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_FREE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_free \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_KEY_LENGTH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_KEY_LENGTH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_key_length \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_KEY_VALUE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_KEY_VALUE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_key_value \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_LENGTH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_LENGTH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_length \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_ST" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_ST" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_st \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_RESULT_VALUE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_RESULT_VALUE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_result_value \- Working with result sets
.
..
.\" Man page generated from reStructeredText.
.
-.sp
-Work with memcached_result_st
.SH SYNOPSIS
.sp
#include <libmemcached/memcached_pool.h>
.INDENT 0.0
.TP
+.B memcached_result_st
+.UNINDENT
+.INDENT 0.0
+.TP
.B memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.UNINDENT
.INDENT 0.0
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_result_flags(const memcached_result_st\fI\ *result\fP)
+.B uint32_t memcached_result_flags(const \fI\%memcached_result_st\fP\fI\ *result\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_result_set_value(memcached_result_st\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
+.B memcached_return_t memcached_result_set_value(\fI\%memcached_result_st\fP\fI\ *ptr\fP, const char\fI\ *value\fP, size_t\fI\ length\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_flags(memcached_result_st\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
+.B void memcached_result_set_flags(\fI\%memcached_result_st\fP\fI\ *ptr\fP, uint32_t\fI\ flags\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_result_set_expiration(memcached_result_st\fI\ *ptr\fP, time_t)
+.B void memcached_result_set_expiration(\fI\%memcached_result_st\fP\fI\ *ptr\fP, time_t)
.UNINDENT
.sp
Compile and link with \-lmemcachedutil \-lmemcached
-.TH "MEMCACHED_SASL" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SASL" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_sasl \- libmemcached Documentation
.
-.TH "MEMCACHED_SASL_SET_AUTH_DATA" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SASL_SET_AUTH_DATA" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_sasl_set_auth_data \- libmemcached Documentation
.
-.TH "MEMCACHED_SERVER_ADD" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_ADD" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_add \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_ADD_UNIX_SOCKET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_ADD_UNIX_SOCKET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_add_unix_socket \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_COUNT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_COUNT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_count \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_CURSOR" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_CURSOR" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_cursor \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_LIST" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_LIST" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_list \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_LIST_APPEND" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_LIST_APPEND" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_list_append \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B const memcached_server_instance_st memcached_server_list (memcached_st *ptr);
+.B memcached_server_instance_st
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_list_free (memcached_server_list_st list);
+.B const \fI\%memcached_server_instance_st\fP memcached_server_list(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error);
+.B void memcached_server_list_free(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_server_list_count (memcached_server_list_st list);
+.B memcached_server_list_st memcached_server_list_append(memcached_server_list_st\fI\ list\fP, const char\fI\ *hostname\fP, unsigned int\fI\ port\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B const char *memcached_server_error (memcached_server_instance_st instance);
+.B uint32_t memcached_server_list_count(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED
+.B const char *memcached_server_error(\fI\%memcached_server_instance_st\fP\fI\ instance\fP)
.UNINDENT
+.INDENT 0.0
+.TP
+.B void memcached_server_error_reset(\fI\%memcached_server_instance_st\fP\fI\ list\fP)
+.UNINDENT
+.sp
+Deprecated since version 0.39.
.sp
Compile and link with \-lmemcached
.SH DESCRIPTION
directly. Functions are provided to modify these structures (and more can be
added, just ask!).
.sp
-memcached_server_list() is used to provide an array of all defined hosts.
+\fI\%memcached_server_list()\fP is used to provide an array of all defined hosts.
This was incorrectly documented as "requiring free()" up till version 0.39.
.sp
-memcached_server_list_free() deallocates all memory associated with the array
+\fI\%memcached_server_list_free()\fP deallocates all memory associated with the array
of memcached_server_st that you passed to it.
.sp
-memcached_server_list_append() adds a server to the end of a
+\fI\%memcached_server_list_append()\fP adds a server to the end of a
memcached_server_st array. On error null will be returned and the
memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
.sp
-DEPRECATED memcached_servers_parse(), please see \fImemcached(3)\fP
+DEPRECATED \fBmemcached_servers_parse()\fP, please see \fBmemcached()\fP
.sp
-memcached_server_error() can be used to look at the text of the last error
+\fI\%memcached_server_error()\fP can be used to look at the text of the last error
message sent by the server to to the client.
.sp
-Before version 0.39 theses functions used a memcache_server_st *. In 0.39
-memcached_server_st * was aliased to memcached_server_list_st. This was
+Before version 0.39 these functions used a memcache_server_st *. In 0.39
+memcached_server_st * was aliased to \fBmemcached_server_list_st\fP. This was
done for a style reason/to help clean up some concepts in the code.
.SH RETURN
.sp
-.TH "MEMCACHED_SERVER_LIST_COUNT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_LIST_COUNT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_list_count \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B const memcached_server_instance_st memcached_server_list (memcached_st *ptr);
+.B memcached_server_instance_st
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_list_free (memcached_server_list_st list);
+.B const \fI\%memcached_server_instance_st\fP memcached_server_list(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error);
+.B void memcached_server_list_free(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_server_list_count (memcached_server_list_st list);
+.B memcached_server_list_st memcached_server_list_append(memcached_server_list_st\fI\ list\fP, const char\fI\ *hostname\fP, unsigned int\fI\ port\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B const char *memcached_server_error (memcached_server_instance_st instance);
+.B uint32_t memcached_server_list_count(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED
+.B const char *memcached_server_error(\fI\%memcached_server_instance_st\fP\fI\ instance\fP)
.UNINDENT
+.INDENT 0.0
+.TP
+.B void memcached_server_error_reset(\fI\%memcached_server_instance_st\fP\fI\ list\fP)
+.UNINDENT
+.sp
+Deprecated since version 0.39.
.sp
Compile and link with \-lmemcached
.SH DESCRIPTION
directly. Functions are provided to modify these structures (and more can be
added, just ask!).
.sp
-memcached_server_list() is used to provide an array of all defined hosts.
+\fI\%memcached_server_list()\fP is used to provide an array of all defined hosts.
This was incorrectly documented as "requiring free()" up till version 0.39.
.sp
-memcached_server_list_free() deallocates all memory associated with the array
+\fI\%memcached_server_list_free()\fP deallocates all memory associated with the array
of memcached_server_st that you passed to it.
.sp
-memcached_server_list_append() adds a server to the end of a
+\fI\%memcached_server_list_append()\fP adds a server to the end of a
memcached_server_st array. On error null will be returned and the
memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
.sp
-DEPRECATED memcached_servers_parse(), please see \fImemcached(3)\fP
+DEPRECATED \fBmemcached_servers_parse()\fP, please see \fBmemcached()\fP
.sp
-memcached_server_error() can be used to look at the text of the last error
+\fI\%memcached_server_error()\fP can be used to look at the text of the last error
message sent by the server to to the client.
.sp
-Before version 0.39 theses functions used a memcache_server_st *. In 0.39
-memcached_server_st * was aliased to memcached_server_list_st. This was
+Before version 0.39 these functions used a memcache_server_st *. In 0.39
+memcached_server_st * was aliased to \fBmemcached_server_list_st\fP. This was
done for a style reason/to help clean up some concepts in the code.
.SH RETURN
.sp
-.TH "MEMCACHED_SERVER_LIST_FREE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_LIST_FREE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_list_free \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B const memcached_server_instance_st memcached_server_list (memcached_st *ptr);
+.B memcached_server_instance_st
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_list_free (memcached_server_list_st list);
+.B const \fI\%memcached_server_instance_st\fP memcached_server_list(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error);
+.B void memcached_server_list_free(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_server_list_count (memcached_server_list_st list);
+.B memcached_server_list_st memcached_server_list_append(memcached_server_list_st\fI\ list\fP, const char\fI\ *hostname\fP, unsigned int\fI\ port\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B const char *memcached_server_error (memcached_server_instance_st instance);
+.B uint32_t memcached_server_list_count(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED
+.B const char *memcached_server_error(\fI\%memcached_server_instance_st\fP\fI\ instance\fP)
.UNINDENT
+.INDENT 0.0
+.TP
+.B void memcached_server_error_reset(\fI\%memcached_server_instance_st\fP\fI\ list\fP)
+.UNINDENT
+.sp
+Deprecated since version 0.39.
.sp
Compile and link with \-lmemcached
.SH DESCRIPTION
directly. Functions are provided to modify these structures (and more can be
added, just ask!).
.sp
-memcached_server_list() is used to provide an array of all defined hosts.
+\fI\%memcached_server_list()\fP is used to provide an array of all defined hosts.
This was incorrectly documented as "requiring free()" up till version 0.39.
.sp
-memcached_server_list_free() deallocates all memory associated with the array
+\fI\%memcached_server_list_free()\fP deallocates all memory associated with the array
of memcached_server_st that you passed to it.
.sp
-memcached_server_list_append() adds a server to the end of a
+\fI\%memcached_server_list_append()\fP adds a server to the end of a
memcached_server_st array. On error null will be returned and the
memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
.sp
-DEPRECATED memcached_servers_parse(), please see \fImemcached(3)\fP
+DEPRECATED \fBmemcached_servers_parse()\fP, please see \fBmemcached()\fP
.sp
-memcached_server_error() can be used to look at the text of the last error
+\fI\%memcached_server_error()\fP can be used to look at the text of the last error
message sent by the server to to the client.
.sp
-Before version 0.39 theses functions used a memcache_server_st *. In 0.39
-memcached_server_st * was aliased to memcached_server_list_st. This was
+Before version 0.39 these functions used a memcache_server_st *. In 0.39
+memcached_server_st * was aliased to \fBmemcached_server_list_st\fP. This was
done for a style reason/to help clean up some concepts in the code.
.SH RETURN
.sp
-.TH "MEMCACHED_SERVER_PUSH" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_PUSH" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_push \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVER_ST" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVER_ST" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_server_st \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVERS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVERS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_servers \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B uint32_t memcached_server_count (memcached_st *ptr);
+.B memcached_server_fn
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.B uint32_t memcached_server_count(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.B memcached_return_t memcached_server_add(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.B memcached_return_t memcached_server_add_udp(memcached_st\fI\ *ptr\fP, const char\fI\ *hostname\fP, in_port_t\fI\ port\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.B memcached_return_t memcached_server_add_unix_socket(memcached_st\fI\ *ptr\fP, const char\fI\ *socket\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.B memcached_return_t memcached_server_push(memcached_st\fI\ *ptr\fP, const memcached_server_st\fI\ *list\fP)
+.UNINDENT
+.INDENT 0.0
+.TP
+.B memcached_server_instance_st memcached_server_by_key(const memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.B memcached_return_t memcached_server_cursor(const memcached_st\fI\ *ptr\fP, const \fI\%memcached_server_fn\fP\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
.UNINDENT
.sp
compile and link with \-lmemcached
.SH DESCRIPTION
.sp
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+\fBlibmemcached\fP performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
+\fBmemcached_server_st()\fP.
.sp
-memcached_server_count() provides you a count of the current number of
-servers being used by a \fBmemcached_st\fP structure.
+\fI\%memcached_server_count()\fP provides you a count of the current
+number of servers being used by a \fBmemcached_st\fP structure.
.sp
-memcached_server_add() pushes a single TCP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add()\fP pushes a single TCP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior set will
+result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_udp() pushes a single UDP server into the \fBmemcached_st\fPstructure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior will result in a
-\fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
+\fI\%memcached_server_add_udp()\fP pushes a single UDP server into the
+\fBmemcached_st\fP structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the \fBMEMCACHED_BEHAVIOR_USE_UDP\fP behavior
+will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP.
.sp
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\fBmemcached_st\fP structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
+\fI\%memcached_server_add_unix_socket()\fP pushes a single UNIX socket
+into the \fBmemcached_st\fP structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+\fBMEMCACHED_MAX_HOST_LENGTH\fP.
.sp
-memcached_server_push() pushes an array of \fBmemcached_server_st\fP into
-the \fBmemcached_st\fP structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
+\fI\%memcached_server_push()\fP pushes an array of
+\fBmemcached_server_st\fP into the \fBmemcached_st\fP structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
.sp
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult *error. The returning structure should be freed with
-memcached_server_free().
+\fI\%memcached_server_by_key()\fP allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult *error. The returning structure should be freed with
+\fBmemcached_server_free()\fP.
.sp
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
+\fI\%memcached_server_get_last_disconnect()\fP returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
.sp
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+\fI\%memcached_server_cursor()\fP takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. \fI\%memcached_server_cursor()\fP is
+passed the original caller memcached_st in its current state.
.SH RETURN
.sp
Varies, see particular functions.
-.TH "MEMCACHED_SERVERS_PARSE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVERS_PARSE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_servers_parse \- libmemcached Documentation
.
#include <libmemcached/memcached.h>
.INDENT 0.0
.TP
-.B const memcached_server_instance_st memcached_server_list (memcached_st *ptr);
+.B memcached_server_instance_st
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_list_free (memcached_server_list_st list);
+.B const \fI\%memcached_server_instance_st\fP memcached_server_list(memcached_st\fI\ *ptr\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error);
+.B void memcached_server_list_free(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B uint32_t memcached_server_list_count (memcached_server_list_st list);
+.B memcached_server_list_st memcached_server_list_append(memcached_server_list_st\fI\ list\fP, const char\fI\ *hostname\fP, unsigned int\fI\ port\fP, memcached_return_t\fI\ *error\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B const char *memcached_server_error (memcached_server_instance_st instance);
+.B uint32_t memcached_server_list_count(memcached_server_list_st\fI\ list\fP)
.UNINDENT
.INDENT 0.0
.TP
-.B void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED
+.B const char *memcached_server_error(\fI\%memcached_server_instance_st\fP\fI\ instance\fP)
.UNINDENT
+.INDENT 0.0
+.TP
+.B void memcached_server_error_reset(\fI\%memcached_server_instance_st\fP\fI\ list\fP)
+.UNINDENT
+.sp
+Deprecated since version 0.39.
.sp
Compile and link with \-lmemcached
.SH DESCRIPTION
directly. Functions are provided to modify these structures (and more can be
added, just ask!).
.sp
-memcached_server_list() is used to provide an array of all defined hosts.
+\fI\%memcached_server_list()\fP is used to provide an array of all defined hosts.
This was incorrectly documented as "requiring free()" up till version 0.39.
.sp
-memcached_server_list_free() deallocates all memory associated with the array
+\fI\%memcached_server_list_free()\fP deallocates all memory associated with the array
of memcached_server_st that you passed to it.
.sp
-memcached_server_list_append() adds a server to the end of a
+\fI\%memcached_server_list_append()\fP adds a server to the end of a
memcached_server_st array. On error null will be returned and the
memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
.sp
-DEPRECATED memcached_servers_parse(), please see \fImemcached(3)\fP
+DEPRECATED \fBmemcached_servers_parse()\fP, please see \fBmemcached()\fP
.sp
-memcached_server_error() can be used to look at the text of the last error
+\fI\%memcached_server_error()\fP can be used to look at the text of the last error
message sent by the server to to the client.
.sp
-Before version 0.39 theses functions used a memcache_server_st *. In 0.39
-memcached_server_st * was aliased to memcached_server_list_st. This was
+Before version 0.39 these functions used a memcache_server_st *. In 0.39
+memcached_server_st * was aliased to \fBmemcached_server_list_st\fP. This was
done for a style reason/to help clean up some concepts in the code.
.SH RETURN
.sp
-.TH "MEMCACHED_SERVERS_RESET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SERVERS_RESET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_servers_reset \- libmemcached Documentation
.
-.TH "MEMCACHED_SET" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set \- Storing and Replacing Data
.
-.TH "MEMCACHED_SET_BY_KEY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET_BY_KEY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set_by_key \- Storing and Replacing Data
.
-.TH "MEMCACHED_SET_MEMORY_ALLOCATORS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET_MEMORY_ALLOCATORS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set_memory_allocators \- libmemcached Documentation
.
-.TH "MEMCACHED_SET_MEMORY_ALLOCATORS_CONTEXT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET_MEMORY_ALLOCATORS_CONTEXT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set_memory_allocators_context \- libmemcached Documentation
.
-.TH "MEMCACHED_SET_SASL_CALLBACKS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET_SASL_CALLBACKS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set_sasl_callbacks \- libmemcached Documentation
.
-.TH "MEMCACHED_SET_USER_DATA" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_SET_USER_DATA" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_set_user_data \- libmemcached Documentation
.
-.TH "MEMCACHED_STAT" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STAT" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stat \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STAT_EXECUTE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STAT_EXECUTE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stat_execute \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STAT_GET_KEYS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STAT_GET_KEYS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stat_get_keys \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STAT_GET_VALUE" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STAT_GET_VALUE" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stat_get_value \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STAT_SERVERNAME" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STAT_SERVERNAME" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stat_servername \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STATS" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STATS" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_stats \- libmemcached Documentation
.
.sp
memcached_stat_servername() can be used standalone without a \fBmemcached_st\fP to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+\fBmemcached_stat_get_keys()\fP call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
.sp
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
.sp
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+\fBmemcached_stat_get_keys()\fP returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
.sp
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
-.TH "MEMCACHED_STRERROR" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_STRERROR" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_strerror \- libmemcached Documentation
.
-.TH "MEMCACHED_USER_DATA" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_USER_DATA" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_user_data \- libmemcached Documentation
.
-.TH "MEMCACHED_VERBOSITY" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_VERBOSITY" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_verbosity \- libmemcached Documentation
.
-.TH "MEMCACHED_VERSION" "3" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCACHED_VERSION" "3" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcached_version \- libmemcached Documentation
.
-.TH "MEMCAPABLE" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCAPABLE" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcapable \- libmemcached Documentation
.
-.TH "MEMCAT" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCAT" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcat \- libmemcached Documentation
.
-.TH "MEMCP" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMCP" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memcp \- libmemcached Documentation
.
-.TH "MEMDUMP" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMDUMP" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memdump \- libmemcached Documentation
.
-.TH "MEMERROR" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMERROR" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memerror \- libmemcached Documentation
.
-.TH "MEMFLUSH" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMFLUSH" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memflush \- libmemcached Documentation
.
-.TH "MEMRM" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMRM" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memrm \- libmemcached Documentation
.
-.TH "MEMSLAP" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMSLAP" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memslap \- libmemcached Documentation
.
-.TH "MEMSTAT" "1" "June 02, 2011" "0.47" "libmemcached"
+.TH "MEMSTAT" "1" "June 17, 2011" "0.49" "libmemcached"
.SH NAME
memstat \- libmemcached Documentation
.
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
-upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the \*error value when all objects that have been found are returned.
-The final value upon MEMCACHED_END is null. Values returned by
-memcached_fetch() must be freed by the caller. memcached_fetch() will
-be DEPRECATED in the near future, memcached_fetch_result() should be used
-instead.
+upon success and NULL will be returned on failure. :c:type:`MEMCACHD_END` is
+returned by the \*error value when all objects that have been found are
+returned. The final value upon :c:type:`MEMCACHED_END` is null. Values
+returned by memcached_fetch() must be freed by the caller. memcached_fetch()
+will be DEPRECATED in the near future, memcached_fetch_result() should be
+used instead.
memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
memcached_get() and memcached_fetch() will return NULL on error. You must
look at the value of error to determine what the actual error was.
+:c:func:`memcached_fetch_execute()` return :c:type:`MEMCACHED_SUCCESS` if
+all keys were successful. :c:type:`MEMCACHED_NOTFOUND` will be return if no
+keys at all were found.
+
+:c:func:`memcached_fetch()` and :c:func:`memcached_fetch_result()` set error
+to :c:type:`MEMCACHED_END` upon successful conclusion.
+:c:type:`MEMCACHED_NOTFOUND` will be return if no keys at all were found.
+
MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
key allowed for the original memcached ascii server.
Working with result sets
========================
-.. index:: object: memcached_result_st
-
-Work with memcached_result_st
-
-
--------
SYNOPSIS
--------
#include <libmemcached/memcached_pool.h>
+.. c:type:: memcached_result_st
+
.. c:function:: memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.. c:function:: void memcached_result_free (memcached_result_st *result);
=========================
-.. index:: object: memcached_server_instance_st
-
--------
SYNOPSIS
--------
#include <libmemcached/memcached.h>
-
-.. c:function:: const memcached_server_instance_st memcached_server_list (memcached_st *ptr);
-.. c:function:: void memcached_server_list_free (memcached_server_list_st list);
+.. c:type:: memcached_server_instance_st
+
+.. c:function:: const memcached_server_instance_st memcached_server_list (memcached_st *ptr)
+
+.. c:function:: void memcached_server_list_free (memcached_server_list_st list)
-.. c:function:: memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error);
+.. c:function:: memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error)
-.. c:function:: uint32_t memcached_server_list_count (memcached_server_list_st list);
+.. c:function:: uint32_t memcached_server_list_count (memcached_server_list_st list)
-.. c:function:: const char *memcached_server_error (memcached_server_instance_st instance);
+.. c:function:: const char *memcached_server_error (memcached_server_instance_st instance)
-.. c:function:: void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED
+.. c:function:: void memcached_server_error_reset (memcached_server_instance_st list)
+.. deprecated:: 0.39
Compile and link with -lmemcached
directly. Functions are provided to modify these structures (and more can be
added, just ask!).
-memcached_server_list() is used to provide an array of all defined hosts.
+:c:func:`memcached_server_list()` is used to provide an array of all defined hosts.
This was incorrectly documented as "requiring free()" up till version 0.39.
-memcached_server_list_free() deallocates all memory associated with the array
+:c:func:`memcached_server_list_free()` deallocates all memory associated with the array
of memcached_server_st that you passed to it.
-memcached_server_list_append() adds a server to the end of a
+:c:func:`memcached_server_list_append()` adds a server to the end of a
memcached_server_st array. On error null will be returned and the
memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
-DEPRECATED memcached_servers_parse(), please see :manpage:`memcached(3)`
+DEPRECATED :c:func:`memcached_servers_parse()`, please see :c:func:`memcached()`
-memcached_server_error() can be used to look at the text of the last error
+:c:func:`memcached_server_error()` can be used to look at the text of the last error
message sent by the server to to the client.
-Before version 0.39 theses functions used a memcache_server_st \*. In 0.39
-memcached_server_st \* was aliased to memcached_server_list_st. This was
+Before version 0.39 these functions used a memcache_server_st \*. In 0.39
+memcached_server_st \* was aliased to :c:type:`memcached_server_list_st`. This was
done for a style reason/to help clean up some concepts in the code.
Manipulate the server information stored in memcached_st
========================================================
-.. index:: object: memcached_st
-
---------
-SYNOPSIS
+--------
+SYNOPSIS
--------
#include <libmemcached/memcached.h>
-.. c:function:: uint32_t memcached_server_count (memcached_st *ptr);
+.. c:type:: memcached_server_fn
+
+.. c:function:: uint32_t memcached_server_count (memcached_st *ptr)
-.. c:function:: memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port);
+.. c:function:: memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port)
-.. c:function:: memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port);
+.. c:function:: memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port)
-.. c:function:: memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket);
+.. c:function:: memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket)
-.. c:function:: memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list);
+.. c:function:: memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list)
-.. c:function:: memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error);
+.. c:function:: memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error)
.. c:function:: memcached_server_instance_st memcached_server_get_last_disconnect (const memcached_st *ptr)
-.. c:function:: memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks);
+.. c:function:: memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks)
compile and link with -lmemcached
-----------
-libmemcached(3) performs operations on a list of hosts. The order of these
-hosts determine routing to keys. Functions are provided to add keys to
+:doc:`libmemcached` performs operations on a list of hosts. The order of
+these hosts determine routing to keys. Functions are provided to add keys to
memcached_st structures. To manipulate lists of servers see
-memcached_server_st(3).
-
-memcached_server_count() provides you a count of the current number of
-servers being used by a \ ``memcached_st``\ structure.
-
-memcached_server_add() pushes a single TCP server into the \ ``memcached_st``\
-structure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with the
-\ ``MEMCACHED_BEHAVIOR_USE_UDP``\ behavior set will result in a
-\ ``MEMCACHED_INVALID_HOST_PROTOCOL``\ .
-
-memcached_server_add_udp() pushes a single UDP server into the \ ``memcached_st``\
-structure. This server will be placed at the end. Duplicate servers are
-allowed, so duplication is not checked. Executing this function with out
-setting the \ ``MEMCACHED_BEHAVIOR_USE_UDP``\ behavior will result in a
-\ ``MEMCACHED_INVALID_HOST_PROTOCOL``\ .
-
-memcached_server_add_unix_socket() pushes a single UNIX socket into the
-\ ``memcached_st``\ structure. This UNIX socket will be placed at the end.
-Duplicate servers are allowed, so duplication is not checked. The length
-of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH.
-
-memcached_server_push() pushes an array of \ ``memcached_server_st``\ into
-the \ ``memcached_st``\ structure. These servers will be placed at the
-end. Duplicate servers are allowed, so duplication is not checked. A
-copy is made of structure so the list provided (and any operations on
-the list) are not saved.
-
-memcached_server_by_key() allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult \*error. The returning structure should be freed with
-memcached_server_free().
-
-memcached_server_get_last_disconnect() returns a pointer to the last server
-for which there was a connection problem. It does not mean this particular
-server is currently dead but if the library is reporting a server is,
-the returned server is a very good candidate.
-
-memcached_server_cursor() takes a memcached_st and loops through the
-list of hosts currently in the cursor calling the list of callback
-functions provided. You can optionally pass in a value via
-context which will be provided to each callback function. An error
-return from any callback will terminate the loop. memcached_server_cursor()
-is passed the original caller memcached_st in its current state.
+:c:type:`memcached_server_st()`.
+
+:c:func:`memcached_server_count()` provides you a count of the current
+number of servers being used by a :c:type:`memcached_st` structure.
+
+:c:func:`memcached_server_add()` pushes a single TCP server into the
+:c:type:`memcached_st` structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with the :c:type:`MEMCACHED_BEHAVIOR_USE_UDP` behavior set will
+result in a :c:type:`MEMCACHED_INVALID_HOST_PROTOCOL`.
+
+:c:func:`memcached_server_add_udp()` pushes a single UDP server into the
+:c:type:`memcached_st` structure. This server will be placed at the end.
+Duplicate servers are allowed, so duplication is not checked. Executing this
+function with out setting the :c:type:`MEMCACHED_BEHAVIOR_USE_UDP` behavior
+will result in a :c:type:`MEMCACHED_INVALID_HOST_PROTOCOL`.
+
+:c:func:`memcached_server_add_unix_socket()` pushes a single UNIX socket
+into the :c:type:`memcached_st` structure. This UNIX socket will be placed
+at the end. Duplicate servers are allowed, so duplication is not checked.
+The length of the filename must be one character less then
+:c:macro:`MEMCACHED_MAX_HOST_LENGTH`.
+
+:c:func:`memcached_server_push()` pushes an array of
+:c:type:`memcached_server_st` into the :c:type:`memcached_st` structure.
+These servers will be placed at the end. Duplicate servers are allowed, so
+duplication is not checked. A copy is made of structure so the list provided
+(and any operations on the list) are not saved.
+
+:c:func:`memcached_server_by_key()` allows you to provide a key and retrieve
+the server which would be used for assignment. This structure is cloned from
+its original structure and must be freed. If NULL is returned you should
+consult \*error. The returning structure should be freed with
+:c:func:`memcached_server_free()`.
+
+:c:func:`memcached_server_get_last_disconnect()` returns a pointer to the
+last server for which there was a connection problem. It does not mean this
+particular server is currently dead but if the library is reporting a server
+is, the returned server is a very good candidate.
+
+:c:func:`memcached_server_cursor()` takes a memcached_st and loops through
+the list of hosts currently in the cursor calling the list of callback
+functions provided. You can optionally pass in a value via context which
+will be provided to each callback function. An error return from any
+callback will terminate the loop. :c:func:`memcached_server_cursor()` is
+passed the original caller memcached_st in its current state.
------
memcached_stat_servername() can be used standalone without a \ ``memcached_st``\ to
obtain the state of a particular server. "args" is used to define a
-particular state object (a list of these are not provided for by either
-the memcached_stat_get_keys() call nor are they defined in the memcached
-protocol). You must specify the hostname and port of the server you want to
-obtain information on.
+particular state object (a list of these are not provided for by either the
+:c:func:`memcached_stat_get_keys()` call nor are they defined in the
+memcached protocol). You must specify the hostname and port of the server
+you want to obtain information on.
memcached_stat_get_value() returns the value of a particular state key. You
specify the key you wish to obtain. The key must be null terminated.
-memcached_stat_get_keys() returns a list of keys that the server has state
-objects on. You are responsible for freeing this list.
+:c:func:`memcached_stat_get_keys()` returns a list of keys that the server
+has state objects on. You are responsible for freeing this list.
A command line tool, memstat(1), is provided so that you do not have to write
an application to do this.
msg.response.message.body.flags= htonl(item->flags);
char *ptr= (char*)(msg.response.bytes + sizeof(*header) + 4);
uint32_t bodysize= 4;
- msg.response.message.header.response.cas= htonll(item->cas);
+ msg.response.message.header.response.cas= memcached_htonll(item->cas);
if (opcode == PROTOCOL_BINARY_CMD_GETK || opcode == PROTOCOL_BINARY_CMD_GETKQ)
{
memcpy(ptr, item->key, item->nkey);
};
uint16_t keylen= ntohs(header->request.keylen);
- uint64_t initial= ntohll(req->message.body.initial);
- uint64_t delta= ntohll(req->message.body.delta);
+ uint64_t initial= memcached_ntohll(req->message.body.initial);
+ uint64_t delta= memcached_ntohll(req->message.body.delta);
uint32_t expiration= ntohl(req->message.body.expiration);
uint32_t flags= 0;
void *key= req->bytes + sizeof(req->bytes);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
{
response.message.header.response.bodylen= ntohl(8);
- response.message.body.value= ntohll((*(uint64_t*)item->data));
- response.message.header.response.cas= ntohll(item->cas);
+ response.message.body.value= memcached_ntohll((*(uint64_t*)item->data));
+ response.message.header.response.cas= memcached_ntohll(item->cas);
release_item(item);
if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ ||
.opcode= PROTOCOL_BINARY_CMD_VERSION,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
+ .cas= 0,
.bodylen= htonl((uint32_t)strlen(versionstring))
}
};
{
protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS;
uint16_t keylen= ntohs(header->request.keylen);
- uint64_t cas= ntohll(header->request.cas);
+ uint64_t cas= memcached_ntohll(header->request.cas);
void *key= header + 1;
uint32_t vallen= ntohl(header->request.bodylen) - keylen;
void *val= (char*)key + keylen;
.opcode= header->request.opcode,
.status= htons(rval),
.opaque= header->request.opaque,
- .cas= htonll(cas),
+ .cas= memcached_htonll(cas),
}
}
};
struct item* item= get_item(key, keylen);
if (item != NULL)
{
- if (item->cas != ntohll(header->request.cas))
+ if (item->cas != memcached_ntohll(header->request.cas))
{
release_item(item);
response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS);
/* SETQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_SET)
{
- response.message.header.response.cas= htonll(item->cas);
+ response.message.header.response.cas= memcached_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
/* ADDQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_ADD)
{
- response.message.header.response.cas= htonll(item->cas);
+ response.message.header.response.cas= memcached_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
struct item* item= get_item(key, keylen);
if (item == NULL)
+ {
response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT);
- else if (header->request.cas == 0 || ntohll(header->request.cas) == item->cas)
+ }
+ else if (header->request.cas == 0 || memcached_ntohll(header->request.cas) == item->cas)
{
release_item(item);
delete_item(key, keylen);
item= create_item(key, keylen, data, datalen, flags, timeout);
+
if (item == NULL)
+ {
response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM);
+ }
else
{
put_item(item);
/* REPLACEQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE)
{
- response.message.header.response.cas= htonll(item->cas);
+ response.message.header.response.cas= memcached_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
return;
}
- double temp= (double) (total_get_hits/total_get_cmds);
+ double temp= double(total_get_hits) / total_get_cmds;
result->pool_hit_ratio= temp * 100;
}
uint32_t server_count, x;
memcached_analysis_st *result;
+ if (not memc or not memc_stat)
+ return NULL;
+
*error= MEMCACHED_SUCCESS;
server_count= memcached_server_count(memc);
result= (memcached_analysis_st*)calloc(memcached_server_count(memc),
sizeof(memcached_analysis_st));
- if (!result)
+ if (not result)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
request.message.header.request.extlen= 20;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(ptr->prefix_key) +request.message.header.request.extlen));
- request.message.body.delta= htonll(offset);
- request.message.body.initial= htonll(initial);
+ request.message.body.delta= memcached_htonll(offset);
+ request.message.body.initial= memcached_htonll(initial);
request.message.body.expiration= htonl((uint32_t) expiration);
struct libmemcached_io_vector_st vector[]=
*
*/
-#include <libmemcached/common.h>
+#include <config.h>
+
+#include <sys/types.h>
+
+#include <libmemcached/visibility.h>
+#include <libmemcached/byteorder.h>
/* Byte swap a 64-bit number. */
#ifndef swap64
}
#endif
+#ifdef HAVE_HTONLL
+
+uint64_t memcached_ntohll(uint64_t value)
+{
+ return ntohll(value);
+}
+
+uint64_t memcached_htonll(uint64_t value)
+{
+ return htonll(value);
+}
+
+#else // HAVE_HTONLL
+
uint64_t memcached_ntohll(uint64_t value)
{
return swap64(value);
{
return swap64(value);
}
+
+#endif // HAVE_HTONLL
#pragma once
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifndef HAVE_HTONLL
-#define ntohll(a) memcached_ntohll(a)
-#define htonll(a) memcached_htonll(a)
-
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_LOCAL
uint64_t memcached_ntohll(uint64_t);
+
LIBMEMCACHED_LOCAL
uint64_t memcached_htonll(uint64_t);
+
#ifdef __cplusplus
}
#endif
-
-#endif
-
-#ifdef linux
-/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
- * optimize the conversion functions, but the prototypes generate warnings
- * from gcc. The conversion methods isn't the bottleneck for my app, so
- * just remove the warnings by undef'ing the optimization ..
- */
-#undef ntohs
-#undef ntohl
-#undef htons
-#undef htonl
-#endif
fds[0].fd = ptr->fd;
fds[0].events = POLLOUT;
- int error;
size_t loop_max= 5;
while (--loop_max) // Should only loop on cases of ERESTART or EINTR
{
- error= poll(fds, 1, ptr->root->connect_timeout);
+ int error;
+ if (ptr->root->poll_timeout)
+ {
+ error= poll(fds, 1, ptr->root->connect_timeout);
+ }
+ else
+ {
+ error= 0;
+ }
switch (error)
{
{
return MEMCACHED_SUCCESS;
}
- else
- {
- ptr->cached_errno= errno;
- return MEMCACHED_ERRNO;
- }
+ return memcached_set_errno(*ptr, err, MEMCACHED_AT);
}
case 0:
- return MEMCACHED_TIMEOUT;
+ {
+ return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ }
+
default: // A real error occurred and we need to completely bail
WATCHPOINT_ERRNO(get_socket_errno());
switch (get_socket_errno())
#endif
case EINTR:
continue;
- default:
+
+ case EFAULT:
+ case ENOMEM:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+
+ case EINVAL:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid"));
+
+ default: // This should not happen
if (fds[0].revents & POLLERR)
{
int err;
ptr->cached_errno= get_socket_errno();
}
+ WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
(void)closesocket(ptr->fd);
ptr->fd= INVALID_SOCKET;
+ ptr->state= MEMCACHED_SERVER_STATE_NEW;
- return MEMCACHED_ERRNO;
+ return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
}
}
// This should only be possible from ERESTART or EINTR;
- ptr->cached_errno= get_socket_errno();
-
- return MEMCACHED_ERRNO;
+ return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
static memcached_return_t set_hostinfo(memcached_server_st *server)
{
- char str_port[NI_MAXSERV];
-
- assert(! server->address_info); // We cover the case where a programming mistake has been made.
+ WATCHPOINT_ASSERT(not server->address_info); // We cover the case where a programming mistake has been made.
if (server->address_info)
{
freeaddrinfo(server->address_info);
server->address_info_next= NULL;
}
+ char str_port[NI_MAXSERV];
int length= snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port);
if (length >= NI_MAXSERV || length < 0)
return MEMCACHED_FAILURE;
return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_BADFLAGS)"));
case EAI_MEMORY:
- return memcached_set_error(*server, MEMCACHED_ERRNO, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_MEMORY)"));
+ return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_MEMORY)"));
default:
{
WATCHPOINT_STRING(server->hostname);
- WATCHPOINT_STRING(gai_strerror(e));
+ WATCHPOINT_STRING(gai_strerror(errcode));
return memcached_set_error(*server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode)));
}
}
server->address_info_next= server->address_info;
+ server->state= MEMCACHED_SERVER_STATE_ADDRINFO;
return MEMCACHED_SUCCESS;
}
-static inline memcached_return_t set_socket_nonblocking(memcached_server_st *ptr)
+static inline void set_socket_nonblocking(memcached_server_st *ptr)
{
#ifdef WIN32
u_long arg = 1;
if (ioctlsocket(ptr->fd, FIONBIO, &arg) == SOCKET_ERROR)
{
- return memcached_set_errno(*ptr, get_socket_errno(), NULL);
+ memcached_set_errno(*ptr, get_socket_errno(), NULL);
}
#else
int flags;
do
{
flags= fcntl(ptr->fd, F_GETFL, 0);
- }
- while (flags == -1 && (errno == EINTR || errno == EAGAIN));
+ } while (flags == -1 && (errno == EINTR || errno == EAGAIN));
- unlikely (flags == -1)
+ if (flags == -1)
{
- return memcached_set_errno(*ptr, errno, NULL);
+ memcached_set_errno(*ptr, errno, NULL);
}
else if ((flags & O_NONBLOCK) == 0)
{
do
{
rval= fcntl(ptr->fd, F_SETFL, flags | O_NONBLOCK);
- }
- while (rval == -1 && (errno == EINTR || errno == EAGAIN));
+ } while (rval == -1 && (errno == EINTR || errno == EAGAIN));
unlikely (rval == -1)
{
- return memcached_set_errno(*ptr, errno, NULL);
+ memcached_set_errno(*ptr, errno, NULL);
}
}
#endif
- return MEMCACHED_SUCCESS;
}
-static memcached_return_t set_socket_options(memcached_server_st *ptr)
+static void set_socket_options(memcached_server_st *ptr)
{
WATCHPOINT_ASSERT(ptr->fd != -1);
if (ptr->type == MEMCACHED_CONNECTION_UDP)
- return MEMCACHED_SUCCESS;
+ return;
#ifdef HAVE_SNDTIMEO
if (ptr->root->snd_timeout)
error= setsockopt(ptr->fd, SOL_SOCKET, SO_SNDTIMEO,
&waittime, (socklen_t)sizeof(struct timeval));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
#endif
error= setsockopt(ptr->fd, SOL_SOCKET, SO_RCVTIMEO,
&waittime, (socklen_t)sizeof(struct timeval));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
#endif
#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
{
- int set = 1;
+ int set= 1;
int error= setsockopt(ptr->fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
// This is not considered a fatal error
error= setsockopt(ptr->fd, SOL_SOCKET, SO_LINGER,
&linger, (socklen_t)sizeof(struct linger));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
if (ptr->root->flags.tcp_nodelay)
error= setsockopt(ptr->fd, IPPROTO_TCP, TCP_NODELAY,
&flag, (socklen_t)sizeof(int));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
if (ptr->root->flags.tcp_keepalive)
error= setsockopt(ptr->fd, SOL_SOCKET, SO_KEEPALIVE,
&flag, (socklen_t)sizeof(int));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
#ifdef TCP_KEEPIDLE
error= setsockopt(ptr->fd, IPPROTO_TCP, TCP_KEEPIDLE,
&ptr->root->tcp_keepidle, (socklen_t)sizeof(int));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
#endif
error= setsockopt(ptr->fd, SOL_SOCKET, SO_SNDBUF,
&ptr->root->send_size, (socklen_t)sizeof(int));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
if (ptr->root->recv_size > 0)
error= setsockopt(ptr->fd, SOL_SOCKET, SO_RCVBUF,
&ptr->root->recv_size, (socklen_t)sizeof(int));
WATCHPOINT_ASSERT(error == 0);
- if (error)
- return MEMCACHED_FAILURE;
}
/* libmemcached will always use nonblocking IO to avoid write deadlocks */
- return set_socket_nonblocking(ptr);
+ set_socket_nonblocking(ptr);
}
static memcached_return_t unix_socket_connect(memcached_server_st *ptr)
servAddr.sun_family= AF_UNIX;
strncpy(servAddr.sun_path, ptr->hostname, sizeof(servAddr.sun_path)); /* Copy filename */
-test_connect:
- if (connect(ptr->fd,
- (struct sockaddr *)&servAddr,
- sizeof(servAddr)) < 0)
- {
- switch (errno)
+ do {
+ if (connect(ptr->fd, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0)
{
- case EINPROGRESS:
- case EALREADY:
- case EINTR:
- goto test_connect;
- case EISCONN: /* We were spinning waiting on connect */
- break;
- default:
- WATCHPOINT_ERRNO(errno);
- ptr->cached_errno= errno;
- return MEMCACHED_ERRNO;
+ switch (errno)
+ {
+ case EINPROGRESS:
+ case EALREADY:
+ case EINTR:
+ continue;
+
+ case EISCONN: /* We were spinning waiting on connect */
+ {
+ WATCHPOINT_ASSERT(0); // Programmer error
+ break;
+ }
+
+ default:
+ WATCHPOINT_ERRNO(errno);
+ return memcached_set_errno(*ptr, errno, MEMCACHED_AT);
+ }
}
- }
+ } while (0);
+ ptr->state= MEMCACHED_SERVER_STATE_CONNECTED;
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (not ptr->address_info)
{
+ WATCHPOINT_ASSERT(ptr->state == MEMCACHED_SERVER_STATE_NEW);
memcached_return_t rc;
uint32_t counter= 5;
while (--counter)
return memcached_set_errno(*ptr, get_socket_errno(), NULL);
}
- (void)set_socket_options(ptr);
+ set_socket_options(ptr);
/* connect to server */
if ((connect(ptr->fd, ptr->address_info_next->ai_addr, ptr->address_info_next->ai_addrlen) != SOCKET_ERROR))
{
+ ptr->state= MEMCACHED_SERVER_STATE_CONNECTED;
break; // Success
}
/* An error occurred */
- ptr->cached_errno= get_socket_errno();
- switch (ptr->cached_errno)
+ switch (get_socket_errno())
{
+ case ETIMEDOUT:
+ timeout_error_occured= true;
+ break;
+
case EWOULDBLOCK:
case EINPROGRESS: // nonblocking mode - first return
case EALREADY: // nonblocking mode - subsequent returns
{
- memcached_return_t rc;
- rc= connect_poll(ptr);
+ ptr->state= MEMCACHED_SERVER_STATE_IN_PROGRESS;
+ memcached_return_t rc= connect_poll(ptr);
+ if (memcached_success(rc))
+ {
+ ptr->state= MEMCACHED_SERVER_STATE_CONNECTED;
+ return MEMCACHED_SUCCESS;
+ }
+
+ // A timeout here is treated as an error, we will not retry
if (rc == MEMCACHED_TIMEOUT)
+ {
timeout_error_occured= true;
-
- if (rc == MEMCACHED_SUCCESS)
- break;
+ }
}
+ break;
case EISCONN: // we are connected :-)
+ WATCHPOINT_ASSERT(0); // This is a programmer's error
break;
case EINTR: // Special case, we retry ai_addr
+ WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
(void)closesocket(ptr->fd);
ptr->fd= INVALID_SOCKET;
continue;
default:
- (void)closesocket(ptr->fd);
- ptr->fd= INVALID_SOCKET;
- ptr->address_info_next= ptr->address_info_next->ai_next;
break;
}
+
+ WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
+ (void)closesocket(ptr->fd);
+ ptr->fd= INVALID_SOCKET;
+ ptr->address_info_next= ptr->address_info_next->ai_next;
}
- if (ptr->fd == INVALID_SOCKET)
- {
- WATCHPOINT_STRING("Never got a good file descriptor");
+ WATCHPOINT_ASSERT(ptr->fd == INVALID_SOCKET);
- /* Failed to connect. schedule next retry */
- if (ptr->root->retry_timeout)
+ if (timeout_error_occured)
+ {
+ if (ptr->fd != INVALID_SOCKET)
{
- struct timeval next_time;
-
- if (gettimeofday(&next_time, NULL) == 0)
- ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout;
+ (void)closesocket(ptr->fd);
+ ptr->fd= INVALID_SOCKET;
}
+ }
- if (timeout_error_occured)
- return MEMCACHED_TIMEOUT;
+ WATCHPOINT_STRING("Never got a good file descriptor");
+ /* Failed to connect. schedule next retry */
+ if (ptr->root->retry_timeout)
+ {
+ struct timeval next_time;
- return MEMCACHED_ERRNO; /* The last error should be from connect() */
+ if (gettimeofday(&next_time, NULL) == 0)
+ ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout;
}
- return MEMCACHED_SUCCESS; /* The last error should be from connect() */
+ if (timeout_error_occured)
+ return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+
+ return memcached_set_error(*ptr, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); /* The last error should be from connect() */
}
void set_last_disconnected_host(memcached_server_write_instance_st self)
{
set_last_disconnected_host(ptr);
- return MEMCACHED_SERVER_MARKED_DEAD;
+ return memcached_set_error(*ptr, MEMCACHED_SERVER_MARKED_DEAD, MEMCACHED_AT);
}
}
run_distribution((memcached_st *)ptr->root);
}
- return MEMCACHED_SERVER_MARKED_DEAD;
+ return memcached_set_error(*ptr, MEMCACHED_SERVER_MARKED_DEAD, MEMCACHED_AT);
}
/* We need to clean up the multi startup piece */
case MEMCACHED_CONNECTION_TCP:
rc= network_connect(ptr);
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
- if (ptr->fd != INVALID_SOCKET && ptr->root->sasl.callbacks)
+ if (ptr->fd != INVALID_SOCKET and ptr->root->sasl.callbacks)
{
rc= memcached_sasl_authenticate_connection(ptr);
- if (memcached_failed(rc))
+ if (memcached_failed(rc) and ptr->fd != INVALID_SOCKET)
{
+ WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
(void)closesocket(ptr->fd);
ptr->fd= INVALID_SOCKET;
}
}
else
{
+ memcached_set_error(*ptr, rc, MEMCACHED_AT);
ptr->server_failure_counter++;
-
set_last_disconnected_host(ptr);
}
#define MEMCACHED_PREFIX_KEY_MAX_SIZE 128
#define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU
#define MEMCACHED_VERSION_STRING_LENGTH 24
+#define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH 20
enum memcached_server_distribution_t {
{
if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
return MEMCACHED_WRITE_FAILURE;
+
if (send_length + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
memcached_io_write(instance, NULL, 0, true);
}
size_t cmd_size= sizeof(request.bytes) + key_length;
if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
return MEMCACHED_WRITE_FAILURE;
+
if (cmd_size + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
memcached_io_write(instance, NULL, 0, true);
}
*
*/
-#include "common.h"
+#include <libmemcached/common.h>
memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const void *command,
size_t command_length, bool with_flush)
WATCHPOINT_ASSERT(command_length);
WATCHPOINT_ASSERT(command);
- if ((rc= memcached_connect(ptr)) != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc= memcached_connect(ptr)))
{
+ WATCHPOINT_ASSERT(rc == memcached_last_error(ptr->root));
WATCHPOINT_ERROR(rc);
return rc;
}
*/
#include <libmemcached/common.h>
+#include <cassert>
#define MAX_ERROR_LENGTH 2048
struct memcached_error_t
// For memory allocation we use our error since it is a bit more specific
if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO)
{
- local_errno= ENOMEM;
rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
rc= MEMCACHED_ERRNO;
}
+ if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
+
+ if (local_errno == EINVAL)
+ {
+ rc= MEMCACHED_INVALID_ARGUMENTS;
+ }
+
+ if (local_errno == ECONNREFUSED)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
+
memcached_error_t *error= (struct memcached_error_t *)libmemcached_malloc(&memc, sizeof(struct memcached_error_t));
if (not error) // Bad business if this happens
return;
error->rc= rc;
error->local_errno= local_errno;
- if (str)
+ const char *errmsg_ptr;
+ char errmsg[MAX_ERROR_LENGTH];
+ errmsg[0]= 0;
+ errmsg_ptr= errmsg;
+
+ if (local_errno)
+ {
+#ifdef STRERROR_R_CHAR_P
+ errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg));
+#else
+ strerror_r(local_errno, errmsg, sizeof(errmsg));
+ errmsg_ptr= errmsg;
+#endif
+ }
+
+
+ if (str and str->size and local_errno)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s(%s), %.*s -> %s",
+ memcached_strerror(&memc, rc),
+ errmsg_ptr,
+ memcached_string_printf(*str), at);
+ }
+ else if (local_errno)
{
- size_t length= str->size > (size_t)MAX_ERROR_LENGTH ? MAX_ERROR_LENGTH : str->size;
- error->size= length;
- memcpy(error->message, str->c_str, error->size);
- error->message[error->size]= 0;
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s(%s) -> %s",
+ memcached_strerror(&memc, rc),
+ errmsg_ptr,
+ at);
+ }
+ else if (str and str->size)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s, %.*s -> %s",
+ memcached_strerror(&memc, rc),
+ int(str->size), str->c_str, at);
}
else
{
- error->size= 0;
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s -> %s",
+ memcached_strerror(&memc, rc), at);
}
error->next= memc.error_messages;
memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, const char *str, size_t length)
{
+ assert(rc != MEMCACHED_ERRNO);
memcached_string_t tmp= { str, length };
return memcached_set_error(memc, rc, at, tmp);
}
memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, const char *str, size_t length)
{
+ assert(rc != MEMCACHED_ERRNO);
memcached_string_t tmp= { str, length };
return memcached_set_error(self, rc, at, tmp);
}
memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str)
{
+ assert(rc != MEMCACHED_ERRNO);
if (memcached_success(rc))
return MEMCACHED_SUCCESS;
memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, memcached_string_t& str)
{
+ assert(rc != MEMCACHED_ERRNO);
if (memcached_success(rc))
return MEMCACHED_SUCCESS;
memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at)
{
+ assert(rc != MEMCACHED_ERRNO);
if (memcached_success(rc))
return MEMCACHED_SUCCESS;
memcached_return_t memcached_set_error(memcached_st& self, memcached_return_t rc, const char *at)
{
+ assert(rc != MEMCACHED_ERRNO);
if (memcached_success(rc))
return MEMCACHED_SUCCESS;
return memc->error_messages->message;
}
+
+bool memcached_has_current_error(memcached_st &memc)
+{
+ if (memc.error_messages
+ and memc.error_messages->query_id == memc.query_id
+ and memcached_failed(memc.error_messages->rc))
+ {
+ return true;
+ }
+
+ return false;
+}
+
memcached_return_t memcached_last_error(memcached_st *memc)
{
if (not memc)
LIBMEMCACHED_LOCAL
memcached_return_t memcached_set_errno(memcached_server_st&, int local_errno, const char *at);
+LIBMEMCACHED_LOCAL
+bool memcached_has_current_error(memcached_st &memc);
+
#endif
unlikely (ptr->flags.use_udp)
{
+ if (value_length)
+ *value_length= 0;
+
+ if (key_length)
+ *key_length= 0;
+
+ if (flags)
+ *flags= 0;
+
+ if (key)
+ *key= 0;
+
*error= MEMCACHED_NOT_SUPPORTED;
return NULL;
}
result_buffer= memcached_fetch_result(ptr, result_buffer, error);
-
- if (result_buffer == NULL || *error != MEMCACHED_SUCCESS)
+ if (result_buffer == NULL or memcached_failed(*error))
{
WATCHPOINT_ASSERT(result_buffer == NULL);
- *value_length= 0;
+ if (value_length)
+ *value_length= 0;
+
+ if (key_length)
+ *key_length= 0;
+
+ if (flags)
+ *flags= 0;
+
+ if (key)
+ *key= 0;
+
return NULL;
}
- *value_length= memcached_string_length(&result_buffer->value);
+ if (value_length)
+ *value_length= memcached_string_length(&result_buffer->value);
if (key)
{
if (result_buffer->key_length > MEMCACHED_MAX_KEY)
{
*error= MEMCACHED_KEY_TOO_BIG;
- *value_length= 0;
+ if (value_length)
+ *value_length= 0;
+
+ if (key_length)
+ *key_length= 0;
+
+ if (flags)
+ *flags= 0;
+
+ if (key)
+ *key= 0;
return NULL;
}
strncpy(key, result_buffer->item_key, result_buffer->key_length); // For the binary protocol we will cut off the key :(
- *key_length= result_buffer->key_length;
+ if (key_length)
+ *key_length= result_buffer->key_length;
}
- *flags= result_buffer->item_flags;
+ if (flags)
+ *flags= result_buffer->item_flags;
- return memcached_string_c_copy(&result_buffer->value);
+ return memcached_string_take_value(&result_buffer->value);
}
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
{
memcached_server_st *server;
- unlikely (ptr->flags.use_udp)
+ memcached_return_t unused;
+ if (not error)
+ error= &unused;
+
+ if (not ptr)
+ {
+ *error= MEMCACHED_INVALID_ARGUMENTS;
+ return NULL;
+ }
+
+ if (ptr->flags.use_udp)
{
*error= MEMCACHED_NOT_SUPPORTED;
return NULL;
}
- if (result == NULL)
- if ((result= memcached_result_create(ptr, NULL)) == NULL)
- return NULL;
+ if (not result)
+ {
+ // If we have already initialized (ie it is in use) our internal, we
+ // create one.
+ if (memcached_is_initialized(&ptr->result))
+ {
+ if (not (result= memcached_result_create(ptr, NULL)))
+ {
+ *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ return NULL;
+ }
+ }
+ else
+ {
+ result= memcached_result_create(ptr, &ptr->result);
+ }
+ }
- while ((server= memcached_io_get_readable_server(ptr)) != NULL)
+ *error= MEMCACHED_MAXIMUM_RETURN; // We use this to see if we ever go into the loop
+ while ((server= memcached_io_get_readable_server(ptr)))
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
*error= memcached_response(server, buffer, sizeof(buffer), result);
if (*error == MEMCACHED_SUCCESS)
+ {
+ result->count++;
return result;
+ }
else if (*error == MEMCACHED_END)
+ {
memcached_server_response_reset(server);
+ }
else if (*error != MEMCACHED_NOTFOUND)
+ {
break;
+ }
+ }
+
+ if (*error == MEMCACHED_NOTFOUND and result->count)
+ {
+ *error= MEMCACHED_END;
+ }
+ else if (*error == MEMCACHED_MAXIMUM_RETURN and result->count)
+ {
+ *error= MEMCACHED_END;
+ }
+ else if (*error == MEMCACHED_MAXIMUM_RETURN) // while() loop was never entered
+ {
+ *error= MEMCACHED_NOTFOUND;
+ }
+ else if (*error == MEMCACHED_SUCCESS)
+ {
+ *error= MEMCACHED_END;
+ }
+ else if (result->count == 0)
+ {
+ *error= MEMCACHED_NOTFOUND;
}
/* We have completed reading data */
}
else
{
+ result->count= 0;
memcached_string_reset(&result->value);
}
uint32_t number_of_callbacks)
{
memcached_result_st *result= &ptr->result;
- memcached_return_t rc= MEMCACHED_FAILURE;
+ memcached_return_t rc;
+ bool some_errors= false;
- while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL)
+ while ((result= memcached_fetch_result(ptr, result, &rc)))
{
- if (rc == MEMCACHED_SUCCESS)
+ if (memcached_failed(rc) and rc == MEMCACHED_NOTFOUND)
+ {
+ continue;
+ }
+ else if (memcached_failed(rc))
+ {
+ memcached_set_error(*ptr, rc, MEMCACHED_AT);
+ some_errors= true;
+ continue;
+ }
+
+ for (uint32_t x= 0; x < number_of_callbacks; x++)
{
- for (uint32_t x= 0; x < number_of_callbacks; x++)
+ memcached_return_t ret= (*callback[x])(ptr, result, context);
+ if (memcached_failed(ret))
{
- rc= (*callback[x])(ptr, result, context);
- if (rc != MEMCACHED_SUCCESS)
- break;
+ some_errors= true;
+ memcached_set_error(*ptr, ret, MEMCACHED_AT);
+ break;
}
}
}
+
+ if (some_errors)
+ {
+ return MEMCACHED_SOME_ERRORS;
+ }
+
+ // If we were able to run all keys without issue we return
+ // MEMCACHED_SUCCESS
+ if (memcached_success(rc))
+ {
+ return MEMCACHED_SUCCESS;
+ }
+
return rc;
}
*
*/
-#include "libmemcached/common.h"
-#include <iostream>
+#include <libmemcached/common.h>
+#include <cassert>
/*
What happens if no servers exist?
uint32_t *flags,
memcached_return_t *error)
{
- char *value;
- size_t dummy_length;
- uint32_t dummy_flags;
- memcached_return_t dummy_error;
-
unlikely (ptr->flags.use_udp)
{
- *error= MEMCACHED_NOT_SUPPORTED;
+ if (value_length)
+ *value_length= 0;
+
+ *error= memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT);
return NULL;
}
+ uint64_t query_id= ptr->query_id;
+ (void)query_id;
+
/* Request the key */
*error= memcached_mget_by_key_real(ptr, group_key, group_key_length,
(const char * const *)&key,
&key_length, 1, false);
+ assert(ptr->query_id == query_id +1);
+
+
+ if (memcached_failed(*error))
+ {
+ if (memcached_has_current_error(*ptr)) // Find the most accurate error
+ {
+ *error= memcached_last_error(ptr);
+ }
+
+ if (value_length)
+ *value_length= 0;
+
+ return NULL;
+ }
+
+ char *value= memcached_fetch(ptr, NULL, NULL,
+ value_length, flags, error);
+ assert(ptr->query_id == query_id +1);
- value= memcached_fetch(ptr, NULL, NULL,
- value_length, flags, error);
/* This is for historical reasons */
if (*error == MEMCACHED_END)
*error= MEMCACHED_NOTFOUND;
{
if (ptr->get_key_failure && *error == MEMCACHED_NOTFOUND)
{
-
memcached_result_reset(&ptr->result);
memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result);
(memcached_result_flags(&ptr->result)));
if (rc == MEMCACHED_BUFFERED && latch == 0)
+ {
memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0);
+ }
}
else
{
*error= rc;
*value_length= memcached_result_length(&ptr->result);
*flags= memcached_result_flags(&ptr->result);
- return memcached_string_c_copy(&ptr->result.value);
+ return memcached_string_take_value(&ptr->result.value);
}
}
}
+ assert(ptr->query_id == query_id +1);
return NULL;
}
- (void)memcached_fetch(ptr, NULL, NULL,
- &dummy_length, &dummy_flags,
- &dummy_error);
+ size_t dummy_length;
+ uint32_t dummy_flags;
+ memcached_return_t dummy_error;
+
+ char *dummy_value= memcached_fetch(ptr, NULL, NULL,
+ &dummy_length, &dummy_flags,
+ &dummy_error);
WATCHPOINT_ASSERT(dummy_length == 0);
+ WATCHPOINT_ASSERT(dummy_value == 0);
+ assert(ptr->query_id == query_id +1);
return value;
}
const char *get_command= "get ";
uint8_t get_command_length= 4;
unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */
- bool is_group_key_set= false;
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr)))
}
unlikely (ptr->flags.use_udp)
- return MEMCACHED_NOT_SUPPORTED;
+ {
+ return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT);
+ }
LIBMEMCACHED_MEMCACHED_MGET_START();
if (number_of_keys == 0)
- return MEMCACHED_NOTFOUND;
+ {
+ return memcached_set_error(*ptr, MEMCACHED_NOTFOUND, MEMCACHED_AT, memcached_literal_param("number_of_keys was zero"));
+ }
if (ptr->flags.verify_key && (memcached_key_test(keys, key_length, number_of_keys) == MEMCACHED_BAD_KEY_PROVIDED))
{
- return MEMCACHED_BAD_KEY_PROVIDED;
+ return memcached_set_error(*ptr, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("A bad key value was provided"));
}
+ bool is_group_key_set= false;
if (group_key && group_key_length)
{
if (ptr->flags.verify_key and (memcached_key_test((const char * const *)&group_key, &group_key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
- return MEMCACHED_BAD_KEY_PROVIDED;
+ {
+ return memcached_set_error(*ptr, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("A bad group key was provided."));
+ }
master_server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
is_group_key_set= true;
{
rc= memcached_connect(instance);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc))
{
+ memcached_set_error(*instance, rc, MEMCACHED_AT);
continue;
}
hosts_connected++;
{
LIBMEMCACHED_MEMCACHED_MGET_END();
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc))
return rc;
- return MEMCACHED_NO_SERVERS;
+ return memcached_set_error(*ptr, MEMCACHED_NO_SERVERS, MEMCACHED_AT);
}
LIBMEMCACHED_MEMCACHED_MGET_END();
if (failures_occured_in_sending && success_happened)
+ {
return MEMCACHED_SOME_ERRORS;
+ }
if (success_happened)
return MEMCACHED_SUCCESS;
- return MEMCACHED_FAILURE;
+ return MEMCACHED_FAILURE; // Complete failure occurred
}
memcached_return_t memcached_mget_by_key(memcached_st *ptr,
for (uint32_t x= 0; x < number_of_keys; ++x)
{
uint32_t server_key;
- memcached_server_write_instance_st instance;
if (is_group_key_set)
{
server_key= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
}
- instance= memcached_server_instance_fetch(ptr, server_key);
+ memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
if (memcached_server_response_count(instance) == 0)
{
rc= memcached_connect(instance);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc))
continue;
}
size_t number_of_keys,
bool mget_mode)
{
- memcached_return_t rc;
-
if (ptr->number_of_replicas == 0)
{
- rc= simple_binary_mget(ptr, master_server_key, is_group_key_set,
- keys, key_length, number_of_keys, mget_mode);
+ return simple_binary_mget(ptr, master_server_key, is_group_key_set,
+ keys, key_length, number_of_keys, mget_mode);
}
- else
+
+ uint32_t* hash= static_cast<uint32_t*>(libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys));
+ bool* dead_servers= static_cast<bool*>(libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool)));
+
+ if (hash == NULL || dead_servers == NULL)
{
- uint32_t* hash= static_cast<uint32_t*>(libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys));
- bool* dead_servers= static_cast<bool*>(libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool)));
+ libmemcached_free(ptr, hash);
+ libmemcached_free(ptr, dead_servers);
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
- if (hash == NULL || dead_servers == NULL)
+ if (is_group_key_set)
+ {
+ for (size_t x= 0; x < number_of_keys; x++)
{
- libmemcached_free(ptr, hash);
- libmemcached_free(ptr, dead_servers);
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ hash[x]= master_server_key;
}
-
- if (is_group_key_set)
- {
- for (size_t x= 0; x < number_of_keys; x++)
- {
- hash[x]= master_server_key;
- }
- }
- else
+ }
+ else
+ {
+ for (size_t x= 0; x < number_of_keys; x++)
{
- for (size_t x= 0; x < number_of_keys; x++)
- {
- hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
- }
+ hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
}
+ }
- rc= replication_binary_mget(ptr, hash, dead_servers, keys,
- key_length, number_of_keys);
+ memcached_return_t rc= replication_binary_mget(ptr, hash, dead_servers, keys,
+ key_length, number_of_keys);
- libmemcached_free(ptr, hash);
- libmemcached_free(ptr, dead_servers);
+ WATCHPOINT_IFERROR(rc);
+ libmemcached_free(ptr, hash);
+ libmemcached_free(ptr, dead_servers);
- return MEMCACHED_SUCCESS;
- }
-
- return rc;
+ return MEMCACHED_SUCCESS;
}
case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:
{
uint32_t num= ptr->ketama.continuum_points_counter;
- WATCHPOINT_ASSERT(ptr->continuum);
+ WATCHPOINT_ASSERT(ptr->ketama.continuum);
hash= hash;
memcached_continuum_item_st *begin, *end, *left, *right, *middle;
}
WATCHPOINT_ASSERT(ptr);
- WATCHPOINT_ASSERT(ptr->continuum);
+ WATCHPOINT_ASSERT(ptr->ketama.continuum);
WATCHPOINT_ASSERT(memcached_server_count(ptr) * MEMCACHED_POINTS_PER_SERVER <= MEMCACHED_CONTINUUM_SIZE);
ptr->ketama.continuum_points_counter= pointer_counter;
qsort(ptr->ketama.continuum, ptr->ketama.continuum_points_counter, sizeof(memcached_continuum_item_st), continuum_item_cmp);
#ifdef DEBUG
for (uint32_t pointer_index= 0; memcached_server_count(ptr) && pointer_index < ((live_servers * MEMCACHED_POINTS_PER_SERVER) - 1); pointer_index++)
{
- WATCHPOINT_ASSERT(ptr->continuum[pointer_index].value <= ptr->continuum[pointer_index + 1].value);
+ WATCHPOINT_ASSERT(ptr->ketama.continuum[pointer_index].value <= ptr->ketama.continuum[pointer_index + 1].value);
}
#endif
*/
-#include "libmemcached/common.h"
+#include <libmemcached/common.h>
+#include <cassert>
-typedef enum {
+enum memc_read_or_write {
MEM_READ,
MEM_WRITE
-} memc_read_or_write;
+};
static ssize_t io_flush(memcached_server_write_instance_st ptr,
const bool with_flush,
{
memcached_return_t rc= memcached_purge(ptr);
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
+ {
return MEMCACHED_FAILURE;
+ }
}
size_t loop_max= 5;
while (--loop_max) // While loop is for ERESTART or EINTR
{
- error= poll(&fds, 1, ptr->root->poll_timeout);
+ if (ptr->root->poll_timeout) // Mimic 0 causes timeout behavior (not all platforms do this)
+ {
+ error= poll(&fds, 1, ptr->root->poll_timeout);
+ }
+ else
+ {
+ error= 0;
+ }
switch (error)
{
WATCHPOINT_IF_LABELED_NUMBER(!read_or_write && loop_max < 4, "write() times we had to loop, decremented down from 5", loop_max);
return MEMCACHED_SUCCESS;
+
case 0: // Timeout occured, we let the while() loop do its thing.
- return MEMCACHED_TIMEOUT;
+ return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+
default:
WATCHPOINT_ERRNO(get_socket_errno());
switch (get_socket_errno())
#endif
case EINTR:
break;
+
+ case EFAULT:
+ case ENOMEM:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+
+ case EINVAL:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid"));
+
default:
if (fds.revents & POLLERR)
{
}
memcached_quit_server(ptr, true);
- return MEMCACHED_FAILURE;
+ return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
}
}
ptr->cached_errno= get_socket_errno();
memcached_quit_server(ptr, true);
- return MEMCACHED_FAILURE;
+ return memcached_set_error(*ptr, MEMCACHED_FAILURE, MEMCACHED_AT);
}
memcached_return_t memcached_io_wait_for_write(memcached_server_write_instance_st ptr)
/* There is room in the buffer, try to fill it! */
if (ptr->read_buffer_length != MEMCACHED_MAX_BUFFER)
{
- /* Just try a single read to grab what's available */
- ssize_t nr= recv(ptr->fd,
- ptr->read_ptr + ptr->read_data_length,
- MEMCACHED_MAX_BUFFER - ptr->read_data_length,
- 0);
+ do {
+ /* Just try a single read to grab what's available */
+ ssize_t nr= recv(ptr->fd,
+ ptr->read_ptr + ptr->read_data_length,
+ MEMCACHED_MAX_BUFFER - ptr->read_data_length,
+ MSG_DONTWAIT);
+
+ switch (nr)
+ {
+ case SOCKET_ERROR:
+ {
+ switch (get_socket_errno())
+ {
+ case EINTR:
+ continue;
- if (nr > 0)
- {
- ptr->read_data_length+= (size_t)nr;
- ptr->read_buffer_length+= (size_t)nr;
- return true;
- }
+ case EWOULDBLOCK:
+#ifdef USE_EAGAIN
+ case EAGAIN:
+#endif
+#ifdef TARGET_OS_LINUX
+ case ERESTART:
+#endif
+ break; // No IO is fine, we can just move on
+
+ default:
+ memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
+ }
+ }
+ break;
+
+ case 0: // Shutdown on the socket has occurred
+ {
+ memcached_set_error(*ptr, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT);
+ }
+ break;
+
+ default:
+ {
+ ptr->read_data_length+= size_t(nr);
+ ptr->read_buffer_length+= size_t(nr);
+ return true;
+ }
+ break;
+ }
+ } while (0);
}
return false;
}
return false;
}
-#if 0 // Dead code, this should be removed.
-void memcached_io_preread(memcached_st *ptr)
-{
- unsigned int x;
-
- return;
-
- for (x= 0; x < memcached_server_count(ptr); x++)
- {
- if (memcached_server_response_count(ptr, x) &&
- ptr->hosts[x].read_data_length < MEMCACHED_MAX_BUFFER )
- {
- size_t data_read;
-
- data_read= recv(ptr->hosts[x].fd,
- ptr->hosts[x].read_ptr + ptr->hosts[x].read_data_length,
- MEMCACHED_MAX_BUFFER - ptr->hosts[x].read_data_length, 0);
- if (data_read == SOCKET_ERROR)
- continue;
-
- ptr->hosts[x].read_buffer_length+= data_read;
- ptr->hosts[x].read_data_length+= data_read;
- }
- }
-}
-#endif
-
memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
void *buffer, size_t length, ssize_t *nread)
{
- char *buffer_ptr;
+ assert(ptr); // Programmer error
+ char *buffer_ptr= static_cast<char *>(buffer);
- buffer_ptr= static_cast<char *>(buffer);
+ if (ptr->fd == INVALID_SOCKET)
+ {
+ assert(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO));
+ return MEMCACHED_CONNECTION_FAILURE;
+ }
while (length)
{
if (not ptr->read_buffer_length)
{
ssize_t data_read;
-
- while (1)
+ do
{
- data_read= recv(ptr->fd, ptr->read_buffer, MEMCACHED_MAX_BUFFER, 0);
- if (data_read > 0)
- {
- break;
- }
- else if (data_read == SOCKET_ERROR)
+ data_read= recv(ptr->fd, ptr->read_buffer, MEMCACHED_MAX_BUFFER, MSG_DONTWAIT);
+ if (data_read == SOCKET_ERROR)
{
- ptr->cached_errno= get_socket_errno();
- memcached_return_t rc= MEMCACHED_ERRNO;
switch (get_socket_errno())
{
+ case EINTR: // We just retry
+ continue;
+
+ case ETIMEDOUT: // OSX
case EWOULDBLOCK:
#ifdef USE_EAGAIN
case EAGAIN:
#endif
- case EINTR:
#ifdef TARGET_OS_LINUX
case ERESTART:
#endif
- if ((rc= io_wait(ptr, MEM_READ)) == MEMCACHED_SUCCESS)
+ if (memcached_success(io_wait(ptr, MEM_READ)))
+ {
continue;
+ }
+ return MEMCACHED_IN_PROGRESS;
+
/* fall through */
+ case ENOTCONN: // Programmer Error
+ WATCHPOINT_ASSERT(0);
+ case ENOTSOCK:
+ WATCHPOINT_ASSERT(0);
+ case EBADF:
+ assert(ptr->fd != INVALID_SOCKET);
+ case EINVAL:
+ case EFAULT:
+ case ECONNREFUSED:
default:
{
memcached_quit_server(ptr, true);
*nread= -1;
- return memcached_set_error(*ptr, rc, MEMCACHED_AT);
+ return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
}
}
- else
+ else if (data_read == 0)
{
/*
EOF. Any data received so far is incomplete
it will return EGAIN if data is not immediatly available.
*/
WATCHPOINT_STRING("We had a zero length recv()");
+ assert(0);
memcached_quit_server(ptr, true);
*nread= -1;
return memcached_set_error(*ptr, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
}
- }
+ } while (data_read <= 0);
ptr->io_bytes_sent = 0;
ptr->read_data_length= (size_t) data_read;
return MEMCACHED_SUCCESS;
}
+memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr)
+{
+ assert(ptr); // Programmer error
+
+ if (ptr->fd == INVALID_SOCKET)
+ {
+ assert(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO));
+ return MEMCACHED_CONNECTION_FAILURE;
+ }
+
+ ssize_t data_read;
+ char buffer[MEMCACHED_MAX_BUFFER];
+ do
+ {
+ data_read= recv(ptr->fd, ptr->read_buffer, sizeof(buffer), MSG_DONTWAIT);
+ if (data_read == SOCKET_ERROR)
+ {
+ switch (get_socket_errno())
+ {
+ case EINTR: // We just retry
+ continue;
+
+ case ETIMEDOUT: // OSX
+ case EWOULDBLOCK:
+#ifdef USE_EAGAIN
+ case EAGAIN:
+#endif
+#ifdef TARGET_OS_LINUX
+ case ERESTART:
+#endif
+ if (memcached_success(io_wait(ptr, MEM_READ)))
+ {
+ continue;
+ }
+ return MEMCACHED_IN_PROGRESS;
+
+ /* fall through */
+
+ case ENOTCONN: // Programmer Error
+ WATCHPOINT_ASSERT(0);
+ case ENOTSOCK:
+ WATCHPOINT_ASSERT(0);
+ case EBADF:
+ assert(ptr->fd != INVALID_SOCKET);
+ case EINVAL:
+ case EFAULT:
+ case ECONNREFUSED:
+ default:
+ return MEMCACHED_CONNECTION_FAILURE; // We want this!
+ }
+ }
+ } while (data_read > 0);
+
+ return MEMCACHED_CONNECTION_FAILURE;
+}
+
static ssize_t _io_write(memcached_server_write_instance_st ptr,
const void *buffer, size_t length, bool with_flush)
{
if (ptr->write_buffer_offset == buffer_end && ptr->type != MEMCACHED_CONNECTION_UDP)
{
- memcached_return_t rc;
- ssize_t sent_length;
-
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
- sent_length= io_flush(ptr, with_flush, &rc);
+
+ memcached_return_t rc;
+ ssize_t sent_length= io_flush(ptr, with_flush, &rc);
if (sent_length == -1)
{
return -1;
}
-memcached_return_t memcached_io_close(memcached_server_write_instance_st ptr)
+void memcached_io_close(memcached_server_write_instance_st ptr)
{
if (ptr->fd == INVALID_SOCKET)
{
- return MEMCACHED_SUCCESS;
+ return;
}
/* in case of death shutdown to avoid blocking at close() */
{
WATCHPOINT_ERRNO(get_socket_errno());
}
-
- return MEMCACHED_SUCCESS;
+ ptr->state= MEMCACHED_SERVER_STATE_NEW;
+ ptr->fd= INVALID_SOCKET;
}
memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st *memc)
struct pollfd fds[MAX_SERVERS_TO_POLL];
unsigned int host_index= 0;
- for (uint32_t x= 0;
- x< memcached_server_count(memc) && host_index < MAX_SERVERS_TO_POLL;
- ++x)
+ for (uint32_t x= 0; x < memcached_server_count(memc) && host_index < MAX_SERVERS_TO_POLL; ++x)
{
memcached_server_write_instance_st instance=
memcached_server_instance_fetch(memc, x);
// UDP Sanity check, make sure that we are not sending somthing too big
if (ptr->type == MEMCACHED_CONNECTION_UDP && write_length > MAX_UDP_DATAGRAM_LENGTH)
{
+ *error= MEMCACHED_WRITE_FAILURE;
return -1;
}
if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP
&& ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
+ {
return 0;
+ }
/* Looking for memory overflows */
#if defined(DEBUG)
* buffer for more data and retry the write before
* waiting..
*/
- if (repack_input_buffer(ptr) ||
+ if (repack_input_buffer(ptr) or
process_input_buffer(ptr))
+ {
continue;
+ }
- memcached_return_t rc;
- rc= io_wait(ptr, MEM_WRITE);
-
- if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT)
+ memcached_return_t rc= io_wait(ptr, MEM_WRITE);
+ if (memcached_success(rc))
+ {
continue;
+ }
+ else if (rc == MEMCACHED_TIMEOUT)
+ {
+ *error= memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ return -1;
+ }
memcached_quit_server(ptr, true);
+ *error= memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
return -1;
}
case ENOTCONN:
case EPIPE:
default:
memcached_quit_server(ptr, true);
- *error= MEMCACHED_ERRNO;
+ *error= memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
WATCHPOINT_ASSERT(ptr->fd == -1);
return -1;
}
}
- if (ptr->type == MEMCACHED_CONNECTION_UDP &&
+ if (ptr->type == MEMCACHED_CONNECTION_UDP and
(size_t)sent_length != write_length)
{
memcached_quit_server(ptr, true);
+ *error= memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
return -1;
}
while (offset < size)
{
ssize_t nread;
- memcached_return_t rc= memcached_io_read(ptr, data + offset, size - offset,
- &nread);
- if (rc != MEMCACHED_SUCCESS)
+ memcached_return_t rc;
+
+ while (memcached_continue(rc= memcached_io_read(ptr, data + offset, size - offset, &nread))) { };
+
+ if (memcached_failed(rc))
+ {
return rc;
+ }
offset+= (size_t) nread;
}
bool line_complete= false;
size_t total_nr= 0;
- while (!line_complete)
+ while (not line_complete)
{
if (ptr->read_buffer_length == 0)
{
*/
ssize_t nread;
memcached_return_t rc= memcached_io_read(ptr, buffer_ptr, 1, &nread);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc) and rc == MEMCACHED_IN_PROGRESS)
+ {
+ memcached_quit_server(ptr, true);
+ return memcached_set_error(*ptr, rc, MEMCACHED_AT);
+ }
+ else if (memcached_failed(rc))
+ {
return rc;
+ }
if (*buffer_ptr == '\n')
line_complete= true;
size_t size);
LIBMEMCACHED_LOCAL
-memcached_return_t memcached_io_close(memcached_server_write_instance_st ptr);
+void memcached_io_close(memcached_server_write_instance_st ptr);
/* Read n bytes of data from the server and store them in dta */
LIBMEMCACHED_LOCAL
LIBMEMCACHED_LOCAL
memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st *memc);
+LIBMEMCACHED_LOCAL
+memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr);
+
#ifdef __cplusplus
}
#endif
memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source)
{
memcached_return_t rc= MEMCACHED_SUCCESS;
- memcached_st *new_clone;
- if (source == NULL)
+ if (not source)
return memcached_create(clone);
if (clone && memcached_is_allocated(clone))
return NULL;
}
- new_clone= memcached_create(clone);
+ memcached_st *new_clone= memcached_create(clone);
- if (new_clone == NULL)
+ if (not new_clone)
return NULL;
new_clone->flags= source->flags;
*/
bool configure(const std::string &configuration)
{
- return (memcached_success(memcached_parse_configuration(memc, configuration.c_str(), configuration.size())));
+ return memcached_success(memcached_parse_configuration(memc, configuration.c_str(), configuration.size()));
}
/**
*/
bool addServer(const std::string &server_name, in_port_t port)
{
- memcached_return_t rc;
-
- rc= memcached_server_add(memc, server_name.c_str(), port);
-
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_server_add(memc, server_name.c_str(), port));
}
/**
* @return a memcached return structure
*/
memcached_return_t fetch(std::string &key,
- std::vector<char> &ret_val)
+ std::vector<char> &ret_val,
+ uint32_t &flags,
+ uint64_t &cas_value)
{
- char ret_key[MEMCACHED_MAX_KEY];
- size_t value_length= 0;
- size_t key_length= 0;
memcached_return_t rc;
- uint32_t flags= 0;
- char *value= memcached_fetch(memc, ret_key, &key_length,
- &value_length, &flags, &rc);
- if (value && ret_val.empty())
- {
- ret_val.reserve(value_length);
- ret_val.assign(value, value + value_length);
- key.assign(ret_key, key_length);
- free(value);
- }
- else if (value)
+
+ memcached_result_st *result;
+ if ((result= memcached_fetch_result(memc, NULL, &rc)))
{
- free(value);
+ // Key
+ key.assign(memcached_result_key_value(result), memcached_result_key_length(result));
+
+ // Actual value, null terminated
+ ret_val.reserve(memcached_result_length(result) +1);
+ ret_val.assign(memcached_result_value(result),
+ memcached_result_value(result) +memcached_result_length(result));
+
+ // Misc
+ flags= memcached_result_flags(result);
+ cas_value= memcached_result_cas(result);
}
+ memcached_result_free(result);
return rc;
}
+ memcached_return_t fetch(std::string &key,
+ std::vector<char> &ret_val)
+ {
+ uint32_t flags= 0;
+ uint64_t cas_value= 0;
+
+ return fetch(key, ret_val, flags, cas_value);
+ }
+
/**
* Fetches an individual value from the server.
*
free(value);
return true;
}
+
return false;
}
* If the std::vector of keys is empty then we cannot
* call memcached_mget as we will get undefined behavior.
*/
- if (! real_keys.empty())
+ if (not real_keys.empty())
{
- memcached_return_t rc= memcached_mget(memc, &real_keys[0], &key_len[0], real_keys.size());
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_mget(memc, &real_keys[0], &key_len[0], real_keys.size()));
}
return false;
time_t expiration,
uint32_t flags)
{
- memcached_return_t rc= memcached_set_by_key(memc, master_key.c_str(),
- master_key.length(),
- key.c_str(), key.length(),
- &value[0], value.size(),
- expiration,
- flags);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_set_by_key(memc, master_key.c_str(),
+ master_key.length(),
+ key.c_str(), key.length(),
+ &value[0], value.size(),
+ expiration,
+ flags));
}
/**
*/
bool increment(const std::string &key, uint32_t offset, uint64_t *value)
{
- memcached_return_t rc= memcached_increment(memc, key.c_str(), key.length(),
- offset, value);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_increment(memc, key.c_str(), key.length(), offset, value));
}
/**
*/
bool decrement(const std::string &key, uint32_t offset, uint64_t *value)
{
- memcached_return_t rc= memcached_decrement(memc, key.c_str(),
- key.length(),
- offset, value);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_decrement(memc, key.c_str(),
+ key.length(),
+ offset, value));
}
*/
bool add(const std::string &key, const std::vector<char> &value)
{
- memcached_return_t rc= memcached_add(memc, key.c_str(), key.length(),
- &value[0], value.size(), 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_add(memc, key.c_str(), key.length(),
+ &value[0], value.size(), 0, 0));
}
/**
const std::string &key,
const std::vector<char> &value)
{
- memcached_return_t rc= memcached_add_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_add_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0, 0));
}
/**
*/
bool replace(const std::string &key, const std::vector<char> &value)
{
- memcached_return_t rc= memcached_replace(memc, key.c_str(), key.length(),
- &value[0], value.size(),
- 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_replace(memc, key.c_str(), key.length(),
+ &value[0], value.size(),
+ 0, 0));
}
/**
const std::string &key,
const std::vector<char> &value)
{
- memcached_return_t rc= memcached_replace_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_replace_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0, 0));
}
/**
*/
bool prepend(const std::string &key, const std::vector<char> &value)
{
- memcached_return_t rc= memcached_prepend(memc, key.c_str(), key.length(),
- &value[0], value.size(), 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_prepend(memc, key.c_str(), key.length(),
+ &value[0], value.size(), 0, 0));
}
/**
const std::string &key,
const std::vector<char> &value)
{
- memcached_return_t rc= memcached_prepend_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0,
- 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_prepend_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0,
+ 0));
}
/**
*/
bool append(const std::string &key, const std::vector<char> &value)
{
- memcached_return_t rc= memcached_append(memc,
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_append(memc,
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0, 0));
}
/**
const std::string &key,
const std::vector<char> &value)
{
- memcached_return_t rc= memcached_append_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0, 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_append_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0, 0));
}
/**
const std::vector<char> &value,
uint64_t cas_arg)
{
- memcached_return_t rc= memcached_cas(memc, key.c_str(), key.length(),
- &value[0], value.size(),
- 0, 0, cas_arg);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_cas(memc, key.c_str(), key.length(),
+ &value[0], value.size(),
+ 0, 0, cas_arg));
}
/**
const std::vector<char> &value,
uint64_t cas_arg)
{
- memcached_return_t rc= memcached_cas_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- &value[0],
- value.size(),
- 0, 0, cas_arg);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_cas_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ &value[0],
+ value.size(),
+ 0, 0, cas_arg));
}
/**
*/
bool remove(const std::string &key)
{
- memcached_return_t rc= memcached_delete(memc, key.c_str(), key.length(), 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_delete(memc, key.c_str(), key.length(), 0));
}
/**
*/
bool remove(const std::string &key, time_t expiration)
{
- memcached_return_t rc= memcached_delete(memc,
- key.c_str(),
- key.length(),
- expiration);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_delete(memc,
+ key.c_str(),
+ key.length(),
+ expiration));
}
/**
bool removeByKey(const std::string &master_key,
const std::string &key)
{
- memcached_return_t rc= memcached_delete_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- 0);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_delete_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ 0));
}
/**
const std::string &key,
time_t expiration)
{
- memcached_return_t rc= memcached_delete_by_key(memc,
- master_key.c_str(),
- master_key.length(),
- key.c_str(),
- key.length(),
- expiration);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_delete_by_key(memc,
+ master_key.c_str(),
+ master_key.length(),
+ key.c_str(),
+ key.length(),
+ expiration));
}
/**
* memcached servers
* @return true on success; false otherwise
*/
- bool flush(time_t expiration)
+ bool flush(time_t expiration= 0)
{
- memcached_return_t rc= memcached_flush(memc, expiration);
- return (rc == MEMCACHED_SUCCESS);
+ return memcached_success(memcached_flush(memc, expiration));
}
/**
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
memcached_return_t rc= memcached_parse_configuration(memc_ptr, option_string, length);
- if (memcached_failed(rc) && error_buffer && error_buffer_size)
+ if (memcached_failed(rc) and error_buffer and error_buffer_size)
{
strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size);
+ error_buffer[length -1]= 0;
}
bool has_filename= memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE);
.opcode= opcode,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= client->current_command->request.opaque,
- .cas= htonll(cas),
+ .cas= memcached_htonll(cas),
.keylen= htons(keylen),
.extlen= 4,
.bodylen= htonl(bodylen + keylen + 4),
* @param body the length of the body
* @param bodylen the length of the body
*/
-static protocol_binary_response_status
-stat_response_handler(const void *cookie,
- const void *key,
- uint16_t keylen,
- const void *body,
- uint32_t bodylen) {
+static protocol_binary_response_status stat_response_handler(const void *cookie,
+ const void *key,
+ uint16_t keylen,
+ const void *body,
+ uint32_t bodylen)
+{
memcached_protocol_client_st *client= (void*)cookie;
.opaque= client->current_command->request.opaque,
.keylen= htons(keylen),
.bodylen= htonl(bodylen + keylen),
+ .cas= 0
},
};
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= client->current_command->request.opaque,
.bodylen= htonl(textlen),
+ .cas= 0
},
};
.opcode= PROTOCOL_BINARY_CMD_ADD,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(cas)
+ .cas= memcached_ntohll(cas)
}
}
};
{
uint16_t keylen= ntohs(header->request.keylen);
protocol_binary_request_decr *request= (void*)header;
- uint64_t init= ntohll(request->message.body.initial);
- uint64_t delta= ntohll(request->message.body.delta);
+ uint64_t init= memcached_ntohll(request->message.body.initial);
+ uint64_t delta= memcached_ntohll(request->message.body.delta);
uint32_t timeout= ntohl(request->message.body.expiration);
void *key= request->bytes + sizeof(request->bytes);
uint64_t result;
.opcode= PROTOCOL_BINARY_CMD_DECREMENT,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(cas),
+ .cas= memcached_ntohll(cas),
.bodylen= htonl(8)
},
- .body.value= htonll(result)
+ .body.value= memcached_htonll(result)
}
};
rval= response_handler(cookie, header, (void*)&response);
if (client->root->callback->interface.v1.delete != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
- void *key= (header + 1);
- uint64_t cas= ntohll(header->request.cas);
+ void *key= (header +1);
+ uint64_t cas= memcached_ntohll(header->request.cas);
rval= client->root->callback->interface.v1.delete(cookie, key, keylen, cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_DELETE)
{
uint16_t keylen= ntohs(header->request.keylen);
protocol_binary_request_incr *request= (void*)header;
- uint64_t init= ntohll(request->message.body.initial);
- uint64_t delta= ntohll(request->message.body.delta);
+ uint64_t init= memcached_ntohll(request->message.body.initial);
+ uint64_t delta= memcached_ntohll(request->message.body.delta);
uint32_t timeout= ntohl(request->message.body.expiration);
void *key= request->bytes + sizeof(request->bytes);
uint64_t cas;
.opcode= PROTOCOL_BINARY_CMD_INCREMENT,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(cas),
+ .cas= memcached_ntohll(cas),
.bodylen= htonl(8)
},
- .body.value= htonll(result)
+ .body.value= memcached_htonll(result)
}
};
{
uint16_t keylen= ntohs(header->request.keylen);
uint32_t datalen= ntohl(header->request.bodylen) - keylen;
- char *key= (void*)(header + 1);
- char *data= key + keylen;
- uint64_t cas= ntohll(header->request.cas);
+ char *key= (void*)(header +1);
+ char *data= key +keylen;
+ uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.append(cookie, key, keylen,
.opcode= PROTOCOL_BINARY_CMD_APPEND,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(result_cas),
+ .cas= memcached_ntohll(result_cas),
},
}
};
uint32_t datalen= ntohl(header->request.bodylen) - keylen;
char *key= (char*)(header + 1);
char *data= key + keylen;
- uint64_t cas= ntohll(header->request.cas);
+ uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.prepend(cookie, key, keylen,
data, datalen, cas,
.opcode= PROTOCOL_BINARY_CMD_PREPEND,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(result_cas),
+ .cas= memcached_ntohll(result_cas),
},
}
};
uint32_t timeout= ntohl(request->message.body.expiration);
char *key= ((char*)header) + sizeof(*header) + 8;
char *data= key + keylen;
- uint64_t cas= ntohll(header->request.cas);
+ uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.replace(cookie, key, keylen,
.opcode= PROTOCOL_BINARY_CMD_REPLACE,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(result_cas),
+ .cas= memcached_ntohll(result_cas),
},
}
};
uint32_t timeout= ntohl(request->message.body.expiration);
char *key= ((char*)header) + sizeof(*header) + 8;
char *data= key + keylen;
- uint64_t cas= ntohll(header->request.cas);
+ uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
.opcode= PROTOCOL_BINARY_CMD_SET,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
- .cas= ntohll(result_cas),
+ .cas= memcached_ntohll(result_cas),
},
}
};
memcached_return_t memcached_purge(memcached_server_write_instance_st ptr)
{
- uint32_t x;
memcached_return_t ret= MEMCACHED_SUCCESS;
memcached_st *root= (memcached_st *)ptr->root;
{
memcached_set_purging(root, true);
- return MEMCACHED_WRITE_FAILURE;
+ return memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
}
WATCHPOINT_ASSERT(ptr->fd != -1);
result_ptr= memcached_result_create(root, &result);
WATCHPOINT_ASSERT(result_ptr);
- for (x= 0; x < no_msg; x++)
+ for (uint32_t x= 0; x < no_msg; x++)
{
memcached_result_reset(result_ptr);
memcached_return_t rc= memcached_read_one_response(ptr, buffer,
if (rc== MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_UNKNOWN_READ_FAILURE)
{
WATCHPOINT_ERROR(rc);
- ret = rc;
+ ret= rc;
memcached_io_reset(ptr);
+ memcached_set_error(*ptr, rc, MEMCACHED_AT);
}
if (ptr->root->callbacks != NULL)
{
if (io_death == false && ptr->type != MEMCACHED_CONNECTION_UDP && ptr->options.is_shutting_down == false)
{
- memcached_return_t rc;
- char buffer[MEMCACHED_MAX_BUFFER];
-
ptr->options.is_shutting_down= true;
+ memcached_return_t rc;
if (ptr->root->flags.binary_protocol)
{
protocol_binary_request_quit request= {}; // = {.bytes= {0}};
rc= memcached_do(ptr, memcached_literal_param("quit\r\n"), true);
}
- WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
- (void)rc; // Shut up ICC
+ WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_FETCH_NOTFINISHED);
/* read until socket is closed, or there is an error
* closing the socket before all data is read
* In .40 we began to only do this if we had been doing buffered
* requests of had replication enabled.
*/
- if (ptr->root->flags.buffer_requests || ptr->root->number_of_replicas)
+ if (ptr->root->flags.buffer_requests or ptr->root->number_of_replicas)
{
- ssize_t nread;
- while (memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer),
- &nread) == MEMCACHED_SUCCESS) {} ;
+ memcached_return_t rc_slurp;
+ while (memcached_continue(rc_slurp= memcached_io_slurp(ptr))) {} ;
+ WATCHPOINT_ASSERT(rc_slurp == MEMCACHED_CONNECTION_FAILURE);
}
-
/*
* memcached_io_read may call memcached_quit_server with io_death if
* it encounters problems, but we don't care about those occurences.
memcached_io_close(ptr);
}
- ptr->fd= INVALID_SOCKET;
+ ptr->state= MEMCACHED_SERVER_STATE_NEW;
+ ptr->cursor_active= 0;
ptr->io_bytes_sent= 0;
ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
ptr->read_buffer_length= 0;
void memcached_quit(memcached_st *ptr)
{
- if (initialize_query(ptr) != MEMCACHED_SUCCESS)
+ if (memcached_failed(initialize_query(ptr)))
{
return;
}
else
rc= textual_read_one_response(ptr, buffer, buffer_length, result);
- unlikely(rc == MEMCACHED_UNKNOWN_READ_FAILURE ||
- rc == MEMCACHED_PROTOCOL_ERROR ||
- rc == MEMCACHED_CLIENT_ERROR ||
+ unlikely(rc == MEMCACHED_UNKNOWN_READ_FAILURE or
+ rc == MEMCACHED_PROTOCOL_ERROR or
+ rc == MEMCACHED_CLIENT_ERROR or
rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
memcached_io_reset(ptr);
*/
to_read= (value_length) + 2;
memcached_return_t rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length);
- if (memcached_failed(rrc))
+ if (memcached_failed(rrc) and rrc == MEMCACHED_IN_PROGRESS)
+ {
+ memcached_quit_server(ptr, true);
+ return memcached_set_error(*ptr, rrc, MEMCACHED_AT);
+ }
+ else if (memcached_failed(rrc))
+ {
return rrc;
+ }
}
if (read_length != (ssize_t)(value_length + 2))
char *char_ptr;
char_ptr= memcached_string_value_mutable(&result->value);;
char_ptr[value_length]= 0;
- char_ptr[value_length + 1]= 0;
+ char_ptr[value_length +1]= 0;
memcached_string_set_length(&result->value, value_length);
}
memcached_result_st *result)
{
memcached_return_t rc= memcached_io_readline(ptr, buffer, buffer_length);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc))
+ {
return rc;
+ }
switch(buffer[0])
{
header.response.keylen= ntohs(header.response.keylen);
header.response.status= ntohs(header.response.status);
header.response.bodylen= ntohl(header.response.bodylen);
- header.response.cas= ntohll(header.response.cas);
+ header.response.cas= memcached_ntohll(header.response.cas);
uint32_t bodylen= header.response.bodylen;
if (header.response.status == PROTOCOL_BINARY_RESPONSE_SUCCESS ||
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
- val= ntohll(val);
+ val= memcached_ntohll(val);
memcpy(buffer, &val, sizeof(val));
}
break;
self->key_length= 0;
self->item_cas= 0;
self->root= memc;
+ self->count= 0;
self->item_key[0]= 0;
}
{
ptr= static_cast<memcached_result_st *>(libmemcached_malloc(memc, sizeof(memcached_result_st)));
- if (ptr == NULL)
+ if (not ptr)
+ {
return NULL;
+ }
ptr->options.is_allocated= true;
}
}
else
{
+ ptr->count= 0;
ptr->options.is_initialized= false;
}
}
uint64_t item_cas;
memcached_st *root;
memcached_string_st value;
+ uint64_t count;
char item_key[MEMCACHED_MAX_KEY];
struct {
bool is_allocated:1;
enum memcached_return_t {
MEMCACHED_SUCCESS,
MEMCACHED_FAILURE,
- MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() only
- MEMCACHED_CONNECTION_FAILURE, // DEPRECATED
- MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED
+ MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only
+ MEMCACHED_CONNECTION_FAILURE,
+ MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE
MEMCACHED_WRITE_FAILURE,
MEMCACHED_READ_FAILURE,
MEMCACHED_UNKNOWN_READ_FAILURE,
MEMCACHED_PARSE_ERROR,
MEMCACHED_PARSE_USER_ERROR,
MEMCACHED_DEPRECATED,
+ MEMCACHED_IN_PROGRESS,
MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
};
#endif
-#define memcached_success(X) ((X) == MEMCACHED_SUCCESS)
-#define memcached_failed(A) ((A) != MEMCACHED_SUCCESS)
+#define memcached_success(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_SUCCESS or (__memcached_return_t) == MEMCACHED_END)
+#define memcached_failed(__memcached_return_t) ((__memcached_return_t) != MEMCACHED_SUCCESS and (__memcached_return_t) != MEMCACHED_END)
+#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)
*/
#include <libmemcached/common.h>
+#include <iso646.h>
void memcached_set_sasl_callbacks(memcached_st *ptr,
const sasl_callback_t *callbacks)
* @param raddr remote address (out)
* @return true on success false otherwise (errno contains more info)
*/
-static bool resolve_names(int fd, char *laddr, size_t laddr_length, char *raddr, size_t raddr_length)
+static memcached_return_t resolve_names(int fd, char *laddr, size_t laddr_length, char *raddr, size_t raddr_length)
{
char host[NI_MAXHOST];
char port[NI_MAXSERV];
struct sockaddr_storage saddr;
socklen_t salen= sizeof(saddr);
- if ((getsockname(fd, (struct sockaddr *)&saddr, &salen) < 0) ||
- (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host),
- port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0))
+ if (getsockname(fd, (struct sockaddr *)&saddr, &salen) < 0)
{
- return false;
+ return MEMCACHED_ERRNO;
+ }
+
+ if (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0)
+ {
+ return MEMCACHED_HOST_LOOKUP_FAILURE;
}
(void)snprintf(laddr, laddr_length, "%s;%s", host, port);
salen= sizeof(saddr);
- if ((getpeername(fd, (struct sockaddr *)&saddr, &salen) < 0) ||
- (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host),
- port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0))
+ if (getpeername(fd, (struct sockaddr *)&saddr, &salen) < 0)
+ {
+ return MEMCACHED_ERRNO;
+ }
+
+ if (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host),
+ port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0)
{
- return false;
+ return MEMCACHED_HOST_LOOKUP_FAILURE;
}
(void)snprintf(raddr, raddr_length, "%s;%s", host, port);
- return true;
+ return MEMCACHED_SUCCESS;
}
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *server)
{
- memcached_return_t rc;
-
/* SANITY CHECK: SASL can only be used with the binary protocol */
if (!server->root->flags.binary_protocol)
return MEMCACHED_FAILURE;
memcached_server_response_increment(server);
char mech[MEMCACHED_MAX_BUFFER];
- rc= memcached_response(server, mech, sizeof(mech), NULL);
- if (rc != MEMCACHED_SUCCESS)
+ memcached_return_t rc= memcached_response(server, mech, sizeof(mech), NULL);
+ if (memcached_failed(rc))
{
if (rc == MEMCACHED_PROTOCOL_ERROR)
{
char laddr[NI_MAXHOST + NI_MAXSERV];
char raddr[NI_MAXHOST + NI_MAXSERV];
- unlikely (!resolve_names(server->fd, laddr, sizeof(laddr), raddr, sizeof(raddr)))
+ if (memcached_failed(rc= resolve_names(server->fd, laddr, sizeof(laddr), raddr, sizeof(raddr))))
{
- server->cached_errno= errno;
- return MEMCACHED_ERRNO;
+ return rc;
}
sasl_conn_t *conn;
- int ret= sasl_client_new("memcached", server->hostname, laddr, raddr,
- server->root->sasl.callbacks, 0, &conn);
+ int ret= sasl_client_new("memcached", server->hostname, laddr, raddr, server->root->sasl.callbacks, 0, &conn);
if (ret != SASL_OK)
{
return MEMCACHED_AUTH_PROBLEM;
++total;
}
- sasl_callback_t *cb= libmemcached_calloc(clone, total + 1, sizeof(sasl_callback_t));
- if (cb == NULL)
+ sasl_callback_t *callbacks= libmemcached_calloc(clone, total + 1, sizeof(sasl_callback_t));
+ if (callbacks == NULL)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
- memcpy(cb, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
+ memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
/* Now update the context... */
for (size_t x= 0; x < total; ++x)
{
- if (cb[x].id == SASL_CB_USER || cb[x].id == SASL_CB_AUTHNAME)
+ if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
{
- cb[x].context= libmemcached_malloc(clone, strlen(source->sasl.callbacks[x].context));
+ callbacks[x].context= libmemcached_malloc(clone, strlen(source->sasl.callbacks[x].context));
- if (cb[x].context == NULL)
+ if (callbacks[x].context == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
for (size_t y= 0; y < x; ++y)
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
- libmemcached_free(clone, cb);
+ libmemcached_free(clone, callbacks);
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
- strncpy(cb[x].context, source->sasl.callbacks[x].context, sizeof(cb[x].context));
+ strncpy(callbacks[x].context, source->sasl.callbacks[x].context, sizeof(callbacks[x].context));
}
else
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
- libmemcached_free(clone, cb);
+ libmemcached_free(clone, callbacks);
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
memcpy(n, src, src->len + 1 + sizeof(*n));
- cb[x].context= n;
+ callbacks[x].context= n;
}
}
- clone->sasl.callbacks= cb;
+ clone->sasl.callbacks= callbacks;
clone->sasl.is_allocated= true;
return MEMCACHED_SUCCESS;
self->address_info= NULL;
self->address_info_next= NULL;
+ self->state= MEMCACHED_SERVER_STATE_NEW;
+
if (root)
{
self->next_retry= root->retry_timeout;
self->root= root;
self->limit_maxbytes= 0;
- if (hostname == NULL)
+ if (hostname)
{
- self->hostname[0]= 0;
+ strncpy(self->hostname, hostname, NI_MAXHOST - 1);
}
else
{
- strncpy(self->hostname, hostname, NI_MAXHOST - 1);
+ self->hostname[0]= 0;
}
}
}
}
- memcached_st *root= self->root;
- libmemcached_free(root, self);
+ libmemcached_free(self->root, self);
}
uint32_t memcached_servers_set_count(memcached_server_st *servers, uint32_t count)
#pragma once
+enum memcached_server_state_t {
+ MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
+ MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
+ MEMCACHED_SERVER_STATE_IN_PROGRESS,
+ MEMCACHED_SERVER_STATE_CONNECTED
+};
+
struct memcached_server_st {
struct {
bool is_allocated:1;
uint32_t io_bytes_sent; /* # bytes sent since last read */
uint32_t server_failure_counter;
uint32_t weight;
+ enum memcached_server_state_t state;
struct {
uint32_t read;
uint32_t write;
WATCHPOINT_STRING(key);
return MEMCACHED_UNKNOWN_STAT_KEY;
}
- else if (!strcmp("pid", key))
+ else if (not strcmp("pid", key))
{
- memc_stat->pid= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->pid= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("uptime", key))
+ else if (not strcmp("uptime", key))
{
- memc_stat->uptime= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->uptime= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("time", key))
+ else if (not strcmp("time", key))
{
- memc_stat->time= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->time= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("version", key))
+ else if (not strcmp("version", key))
{
memcpy(memc_stat->version, value, strlen(value));
memc_stat->version[strlen(value)]= 0;
}
- else if (!strcmp("pointer_size", key))
+ else if (not strcmp("pointer_size", key))
{
- memc_stat->pointer_size= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->pointer_size= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("rusage_user", key))
+ else if (not strcmp("rusage_user", key))
{
char *walk_ptr;
for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++) {};
*walk_ptr= 0;
walk_ptr++;
- memc_stat->rusage_user_seconds= (uint32_t) strtol(value, (char **)NULL, 10);
- memc_stat->rusage_user_microseconds= (uint32_t) strtol(walk_ptr, (char **)NULL, 10);
+ memc_stat->rusage_user_seconds= strtoul(value, (char **)NULL, 10);
+ memc_stat->rusage_user_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
}
- else if (!strcmp("rusage_system", key))
+ else if (not strcmp("rusage_system", key))
{
char *walk_ptr;
for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++) {};
*walk_ptr= 0;
walk_ptr++;
- memc_stat->rusage_system_seconds= (uint32_t) strtol(value, (char **)NULL, 10);
- memc_stat->rusage_system_microseconds= (uint32_t) strtol(walk_ptr, (char **)NULL, 10);
+ memc_stat->rusage_system_seconds= strtoul(value, (char **)NULL, 10);
+ memc_stat->rusage_system_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
}
- else if (!strcmp("curr_items", key))
+ else if (not strcmp("curr_items", key))
{
- memc_stat->curr_items= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->curr_items= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("total_items", key))
+ else if (not strcmp("total_items", key))
{
- memc_stat->total_items= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->total_items= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("bytes_read", key))
+ else if (not strcmp("bytes_read", key))
{
- memc_stat->bytes_read= (uint32_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes_read= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("bytes_written", key))
+ else if (not strcmp("bytes_written", key))
{
- memc_stat->bytes_written= (uint32_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes_written= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("bytes", key))
+ else if (not strcmp("bytes", key))
{
- memc_stat->bytes= (uint32_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("curr_connections", key))
+ else if (not strcmp("curr_connections", key))
{
- memc_stat->curr_connections= (uint32_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->curr_connections= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("total_connections", key))
+ else if (not strcmp("total_connections", key))
{
- memc_stat->total_connections= (uint32_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->total_connections= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("connection_structures", key))
+ else if (not strcmp("connection_structures", key))
{
- memc_stat->connection_structures= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->connection_structures= strtoul(value, (char **)NULL, 10);
}
- else if (!strcmp("cmd_get", key))
+ else if (not strcmp("cmd_get", key))
{
- memc_stat->cmd_get= (uint64_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->cmd_get= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("cmd_set", key))
+ else if (not strcmp("cmd_set", key))
{
- memc_stat->cmd_set= (uint64_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->cmd_set= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("get_hits", key))
+ else if (not strcmp("get_hits", key))
{
- memc_stat->get_hits= (uint64_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->get_hits= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("get_misses", key))
+ else if (not strcmp("get_misses", key))
{
- memc_stat->get_misses= (uint64_t)strtoll(value, (char **)NULL, 10);
+ memc_stat->get_misses= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("evictions", key))
+ else if (not strcmp("evictions", key))
{
- memc_stat->evictions= (uint64_t)strtoll(value, (char **)NULL, 10);
+ memc_stat->evictions= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("limit_maxbytes", key))
+ else if (not strcmp("limit_maxbytes", key))
{
- memc_stat->limit_maxbytes= (uint64_t) strtoll(value, (char **)NULL, 10);
+ memc_stat->limit_maxbytes= strtoull(value, (char **)NULL, 10);
}
- else if (!strcmp("threads", key))
+ else if (not strcmp("threads", key))
{
- memc_stat->threads= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->threads= strtoul(value, (char **)NULL, 10);
}
- else if (!(strcmp("delete_misses", key) == 0 ||/* New stats in the 1.3 beta */
- strcmp("delete_hits", key) == 0 ||/* Just swallow them for now.. */
- strcmp("incr_misses", key) == 0 ||
- strcmp("incr_hits", key) == 0 ||
- strcmp("decr_misses", key) == 0 ||
- strcmp("decr_hits", key) == 0 ||
- strcmp("cas_misses", key) == 0 ||
- strcmp("cas_hits", key) == 0 ||
- strcmp("cas_badval", key) == 0 ||
- strcmp("cmd_flush", key) == 0 ||
- strcmp("accepting_conns", key) == 0 ||
- strcmp("listen_disabled_num", key) == 0 ||
- strcmp("conn_yields", key) == 0 ||
- strcmp("auth_cmds", key) == 0 ||
- strcmp("auth_errors", key) == 0 ||
- strcmp("reclaimed", key) == 0))
+ else if (not (strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
+ strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */
+ strcmp("incr_misses", key) == 0 or
+ strcmp("incr_hits", key) == 0 or
+ strcmp("decr_misses", key) == 0 or
+ strcmp("decr_hits", key) == 0 or
+ strcmp("cas_misses", key) == 0 or
+ strcmp("cas_hits", key) == 0 or
+ strcmp("cas_badval", key) == 0 or
+ strcmp("cmd_flush", key) == 0 or
+ strcmp("accepting_conns", key) == 0 or
+ strcmp("listen_disabled_num", key) == 0 or
+ strcmp("conn_yields", key) == 0 or
+ strcmp("auth_cmds", key) == 0 or
+ strcmp("auth_errors", key) == 0 or
+ strcmp("reclaimed", key) == 0))
{
WATCHPOINT_STRING(key);
/* return MEMCACHED_UNKNOWN_STAT_KEY; */
*error= MEMCACHED_SUCCESS;
- if (!memcmp("pid", key, sizeof("pid") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pid);
- else if (!memcmp("uptime", key, sizeof("uptime") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->uptime);
- else if (!memcmp("time", key, sizeof("time") -1))
+ if (not memcmp("pid", key, sizeof("pid") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->pid);
+ }
+ else if (not memcmp("uptime", key, sizeof("uptime") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->uptime);
+ }
+ else if (not memcmp("time", key, sizeof("time") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->time);
- else if (!memcmp("version", key, sizeof("version") -1))
+ }
+ else if (not memcmp("version", key, sizeof("version") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%s", memc_stat->version);
- else if (!memcmp("pointer_size", key, sizeof("pointer_size") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pointer_size);
- else if (!memcmp("rusage_user", key, sizeof("rusage_user") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds);
- else if (!memcmp("rusage_system", key, sizeof("rusage_system") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds);
- else if (!memcmp("curr_items", key, sizeof("curr_items") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_items);
- else if (!memcmp("total_items", key, sizeof("total_items") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_items);
- else if (!memcmp("curr_connections", key, sizeof("curr_connections") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_connections);
- else if (!memcmp("total_connections", key, sizeof("total_connections") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_connections);
- else if (!memcmp("connection_structures", key, sizeof("connection_structures") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->connection_structures);
- else if (!memcmp("cmd_get", key, sizeof("cmd_get") -1))
+ }
+ else if (not memcmp("pointer_size", key, sizeof("pointer_size") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->pointer_size);
+ }
+ else if (not memcmp("rusage_user", key, sizeof("rusage_user") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu.%lu", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds);
+ }
+ else if (not memcmp("rusage_system", key, sizeof("rusage_system") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu.%lu", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds);
+ }
+ else if (not memcmp("curr_items", key, sizeof("curr_items") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->curr_items);
+ }
+ else if (not memcmp("total_items", key, sizeof("total_items") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->total_items);
+ }
+ else if (not memcmp("curr_connections", key, sizeof("curr_connections") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->curr_connections);
+ }
+ else if (not memcmp("total_connections", key, sizeof("total_connections") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->total_connections);
+ }
+ else if (not memcmp("connection_structures", key, sizeof("connection_structures") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->connection_structures);
+ }
+ else if (not memcmp("cmd_get", key, sizeof("cmd_get") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_get);
- else if (!memcmp("cmd_set", key, sizeof("cmd_set") -1))
+ }
+ else if (not memcmp("cmd_set", key, sizeof("cmd_set") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_set);
- else if (!memcmp("get_hits", key, sizeof("get_hits") -1))
+ }
+ else if (not memcmp("get_hits", key, sizeof("get_hits") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_hits);
- else if (!memcmp("get_misses", key, sizeof("get_misses") -1))
+ }
+ else if (not memcmp("get_misses", key, sizeof("get_misses") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_misses);
- else if (!memcmp("evictions", key, sizeof("evictions") -1))
+ }
+ else if (not memcmp("evictions", key, sizeof("evictions") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->evictions);
- else if (!memcmp("bytes_read", key, sizeof("bytes_read") -1))
+ }
+ else if (not memcmp("bytes_read", key, sizeof("bytes_read") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_read);
- else if (!memcmp("bytes_written", key, sizeof("bytes_written") -1))
+ }
+ else if (not memcmp("bytes_written", key, sizeof("bytes_written") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_written);
- else if (!memcmp("bytes", key, sizeof("bytes") -1))
+ }
+ else if (not memcmp("bytes", key, sizeof("bytes") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes);
- else if (!memcmp("limit_maxbytes", key, sizeof("limit_maxbytes") -1))
+ }
+ else if (not memcmp("limit_maxbytes", key, sizeof("limit_maxbytes") -1))
+ {
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->limit_maxbytes);
- else if (! memcmp("threads", key, sizeof("threads") -1))
- length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->threads);
+ }
+ else if (not memcmp("threads", key, sizeof("threads") -1))
+ {
+ length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->threads);
+ }
else
{
*error= MEMCACHED_NOTFOUND;
memcached_server_write_instance_st instance,
struct local_context *check)
{
- memcached_return_t rc;
-
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
protocol_binary_request_stats request= {}; // = {.bytes= {0}};
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_STAT;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- if (args != NULL)
+ if (args)
{
size_t len= strlen(args);
- rc= memcached_validate_key_length(len, true);
+ memcached_return_t rc= memcached_validate_key_length(len, true);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
memcached_server_response_decrement(instance);
do
{
- rc= memcached_response(instance, buffer, sizeof(buffer), NULL);
+ memcached_return_t rc= memcached_response(instance, buffer, sizeof(buffer), NULL);
if (rc == MEMCACHED_END)
break;
memcached_stat_st *memcached_stat(memcached_st *self, char *args, memcached_return_t *error)
{
memcached_return_t rc;
- memcached_stat_st *stats;
-
if ((rc= initialize_query(self)) != MEMCACHED_SUCCESS)
{
if (error)
return NULL;
}
- stats= static_cast<memcached_stat_st *>(libmemcached_calloc(self, memcached_server_count(self), sizeof(memcached_stat_st)));
+ memcached_stat_st *stats= static_cast<memcached_stat_st *>(libmemcached_calloc(self, memcached_server_count(self), sizeof(memcached_stat_st)));
- if (! stats)
+ if (not stats)
{
if (error)
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
memcached_server_write_instance_st instance;
memcached_stat_st *stat_instance;
- stat_instance= stats + x;
+ stat_instance= stats +x;
stat_instance->root= self;
const char *hostname, in_port_t port)
{
memcached_st memc;
- memcached_st *memc_ptr;
memcached_server_write_instance_st instance;
memset(memc_stat, 0, sizeof(memcached_stat_st));
- memc_ptr= memcached_create(&memc);
- if (! memc_ptr)
+ memcached_st *memc_ptr= memcached_create(&memc);
+ if (not memc_ptr)
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
memcached_server_add(&memc, hostname, port);
We make a copy of the keys since at some point in the not so distant future
we will add support for "found" keys.
*/
-char ** memcached_stat_get_keys(const memcached_st *ptr,
- memcached_stat_st *memc_stat,
+char ** memcached_stat_get_keys(memcached_st *ptr,
+ memcached_stat_st *,
memcached_return_t *error)
{
- char **list;
- size_t length= sizeof(memcached_stat_keys);
-
- (void)memc_stat;
-
- list= static_cast<char **>(libmemcached_malloc(ptr, length));
+ if (not ptr)
+ return NULL;
+ char **list= static_cast<char **>(libmemcached_malloc(ptr, sizeof(memcached_stat_keys)));
if (not list)
{
- *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ *error= memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
return NULL;
}
return list;
}
-void memcached_stat_free(const memcached_st *ptr, memcached_stat_st *memc_stat)
+void memcached_stat_free(const memcached_st *, memcached_stat_st *memc_stat)
{
- if (memc_stat == NULL)
+ WATCHPOINT_ASSERT(memc_stat); // Be polite, but when debugging catch this as an error
+ if (not memc_stat)
{
- WATCHPOINT_ASSERT(0); /* Be polite, but when debugging catch this as an error */
return;
}
return;
}
- libmemcached_free(ptr, memc_stat);
+ libmemcached_free(NULL, memc_stat);
}
static memcached_return_t call_stat_fn(memcached_st *ptr,
#pragma once
-
struct memcached_stat_st {
- uint32_t connection_structures;
- uint32_t curr_connections;
- uint32_t curr_items;
- uint32_t pid;
- uint32_t pointer_size;
- uint32_t rusage_system_microseconds;
- uint32_t rusage_system_seconds;
- uint32_t rusage_user_microseconds;
- uint32_t rusage_user_seconds;
- uint32_t threads;
- uint32_t time;
- uint32_t total_connections;
- uint32_t total_items;
- uint32_t uptime;
- uint64_t bytes;
- uint64_t bytes_read;
- uint64_t bytes_written;
- uint64_t cmd_get;
- uint64_t cmd_set;
- uint64_t evictions;
- uint64_t get_hits;
- uint64_t get_misses;
- uint64_t limit_maxbytes;
+ unsigned long connection_structures;
+ unsigned long curr_connections;
+ unsigned long curr_items;
+ unsigned long pid;
+ unsigned long pointer_size;
+ unsigned long rusage_system_microseconds;
+ unsigned long rusage_system_seconds;
+ unsigned long rusage_user_microseconds;
+ unsigned long rusage_user_seconds;
+ unsigned long threads;
+ unsigned long time;
+ unsigned long total_connections;
+ unsigned long total_items;
+ unsigned long uptime;
+ unsigned long long bytes;
+ unsigned long long bytes_read;
+ unsigned long long bytes_written;
+ unsigned long long cmd_get;
+ unsigned long long cmd_set;
+ unsigned long long evictions;
+ unsigned long long get_hits;
+ unsigned long long get_misses;
+ unsigned long long limit_maxbytes;
char version[MEMCACHED_VERSION_STRING_LENGTH];
+ void *__future; // @todo create a new structure to place here for future usage
memcached_st *root;
};
const char *key, memcached_return_t *error);
LIBMEMCACHED_API
-char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat,
+char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
memcached_return_t *error);
LIBMEMCACHED_API
bool to_write;
size_t write_length;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- uint32_t server_key;
- memcached_server_write_instance_st instance;
WATCHPOINT_ASSERT(!(value == NULL && value_length > 0));
if (ptr->flags.verify_key && (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
return MEMCACHED_BAD_KEY_PROVIDED;
- server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
- instance= memcached_server_instance_fetch(ptr, server_key);
+ uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
+ memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
WATCHPOINT_SET(instance->io_wait_count.read= 0);
WATCHPOINT_SET(instance->io_wait_count.write= 0);
buffer_ptr++;
write_length= (size_t)(buffer_ptr - buffer);
- int check_length;
- check_length= snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE -(size_t)(buffer_ptr - buffer),
- "%u %llu %lu%s\r\n",
- flags,
- (unsigned long long)expiration, (unsigned long)value_length,
- ptr->flags.no_reply ? " noreply" : "");
- if ((size_t)check_length >= MEMCACHED_DEFAULT_COMMAND_SIZE -(size_t)(buffer_ptr - buffer) || check_length < 0)
+ int check_length= snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE -(size_t)(buffer_ptr - buffer),
+ "%u %llu %lu%s\r\n",
+ flags,
+ (unsigned long long)expiration, (unsigned long)value_length,
+ ptr->flags.no_reply ? " noreply" : "");
+ if ((size_t)check_length >= MEMCACHED_DEFAULT_COMMAND_SIZE -size_t(buffer_ptr - buffer) || check_length < 0)
{
rc= MEMCACHED_WRITE_FAILURE;
memcached_io_reset(instance);
if (ptr->flags.use_udp && ptr->flags.buffer_requests)
{
- size_t cmd_size= write_length + value_length + 2;
+ size_t cmd_size= write_length + value_length +2;
if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
- return MEMCACHED_WRITE_FAILURE;
+ return memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
+
if (cmd_size + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
memcached_io_write(instance, NULL, 0, true);
}
if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
{
- rc= MEMCACHED_WRITE_FAILURE;
+ rc= memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
}
else
{
request.message.header.request.extlen));
if (cas)
- request.message.header.request.cas= htonll(cas);
+ request.message.header.request.cas= memcached_htonll(cas);
flush= (bool) ((server->root->flags.buffer_requests && verb == SET_OP) ? 0 : 1);
{
case MEMCACHED_SUCCESS:
return "SUCCESS";
+
case MEMCACHED_FAILURE:
return "FAILURE";
+
case MEMCACHED_HOST_LOOKUP_FAILURE: // getaddrinfo only
- return "getaddrinfo() HOSTNAME LOOKUP FAILURE";
- case MEMCACHED_CONNECTION_FAILURE: // DEPRECATED
+ return "getaddrinfo() or getnameinfo() HOSTNAME LOOKUP FAILURE";
+
+ case MEMCACHED_CONNECTION_FAILURE:
return "CONNECTION FAILURE";
- case MEMCACHED_CONNECTION_BIND_FAILURE:
+
+ case MEMCACHED_CONNECTION_BIND_FAILURE: // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE
return "CONNECTION BIND FAILURE";
+
case MEMCACHED_READ_FAILURE:
return "READ FAILURE";
+
case MEMCACHED_UNKNOWN_READ_FAILURE:
return "UNKNOWN READ FAILURE";
+
case MEMCACHED_PROTOCOL_ERROR:
return "PROTOCOL ERROR";
+
case MEMCACHED_CLIENT_ERROR:
return "CLIENT ERROR";
+
case MEMCACHED_SERVER_ERROR:
return "SERVER ERROR";
+
case MEMCACHED_WRITE_FAILURE:
return "WRITE FAILURE";
+
case MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE: // DEPRECATED
return "CONNECTION SOCKET CREATE FAILURE";
+
case MEMCACHED_DATA_EXISTS:
return "CONNECTION DATA EXISTS";
+
case MEMCACHED_DATA_DOES_NOT_EXIST:
return "CONNECTION DATA DOES NOT EXIST";
+
case MEMCACHED_NOTSTORED:
return "NOT STORED";
+
case MEMCACHED_STORED:
return "STORED";
+
case MEMCACHED_NOTFOUND:
return "NOT FOUND";
+
case MEMCACHED_MEMORY_ALLOCATION_FAILURE:
return "MEMORY ALLOCATION FAILURE";
+
case MEMCACHED_PARTIAL_READ:
return "PARTIAL READ";
+
case MEMCACHED_SOME_ERRORS:
return "SOME ERRORS WERE REPORTED";
+
case MEMCACHED_NO_SERVERS:
return "NO SERVERS DEFINED";
+
case MEMCACHED_END:
return "SERVER END";
+
case MEMCACHED_DELETED:
return "SERVER DELETE";
+
case MEMCACHED_VALUE:
return "SERVER VALUE";
+
case MEMCACHED_STAT:
return "STAT VALUE";
+
case MEMCACHED_ITEM:
return "ITEM VALUE";
+
case MEMCACHED_ERRNO:
return "SYSTEM ERROR";
+
case MEMCACHED_FAIL_UNIX_SOCKET:
return "COULD NOT OPEN UNIX SOCKET";
+
case MEMCACHED_NOT_SUPPORTED:
return "ACTION NOT SUPPORTED";
+
case MEMCACHED_FETCH_NOTFINISHED:
return "FETCH WAS NOT COMPLETED";
+
case MEMCACHED_NO_KEY_PROVIDED:
return "A KEY LENGTH OF ZERO WAS PROVIDED";
+
case MEMCACHED_BUFFERED:
return "ACTION QUEUED";
+
case MEMCACHED_TIMEOUT:
return "A TIMEOUT OCCURRED";
+
case MEMCACHED_BAD_KEY_PROVIDED:
return "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE";
+
case MEMCACHED_INVALID_HOST_PROTOCOL:
return "THE HOST TRANSPORT PROTOCOL DOES NOT MATCH THAT OF THE CLIENT";
+
case MEMCACHED_SERVER_MARKED_DEAD:
return "SERVER IS MARKED DEAD";
+
case MEMCACHED_UNKNOWN_STAT_KEY:
return "ENCOUNTERED AN UNKNOWN STAT KEY";
+
case MEMCACHED_E2BIG:
return "ITEM TOO BIG";
+
case MEMCACHED_INVALID_ARGUMENTS:
return "INVALID ARGUMENTS";
+
case MEMCACHED_KEY_TOO_BIG:
return "KEY RETURNED FROM SERVER WAS TOO LARGE";
+
case MEMCACHED_AUTH_PROBLEM:
return "FAILED TO SEND AUTHENTICATION TO SERVER";
+
case MEMCACHED_AUTH_FAILURE:
return "AUTHENTICATION FAILURE";
+
case MEMCACHED_AUTH_CONTINUE:
return "CONTINUE AUTHENTICATION";
+
case MEMCACHED_PARSE_ERROR:
return "ERROR OCCURED WHILE PARSING";
+
case MEMCACHED_PARSE_USER_ERROR:
return "USER INITIATED ERROR OCCURED WHILE PARSING";
+
case MEMCACHED_DEPRECATED:
return "DEPRECATED";
+
+ case MEMCACHED_IN_PROGRESS:
+ return "OPERATION IN PROCESS";
+
default:
case MEMCACHED_MAXIMUM_RETURN:
return "INVALID memcached_return_t";
#include <libmemcached/common.h>
+#include <cassert>
inline static memcached_return_t _string_check(memcached_string_st *string, size_t need)
{
return self;
}
+static memcached_return_t memcached_string_append_null(memcached_string_st *string)
+{
+ if (memcached_failed(_string_check(string, 1)))
+ {
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
+
+ *string->end= 0;
+
+ return MEMCACHED_SUCCESS;
+}
+
memcached_return_t memcached_string_append_character(memcached_string_st *string,
char character)
{
return self->string;
}
+char *memcached_string_take_value(memcached_string_st *self)
+{
+ assert(self);
+ // If we fail at adding the null, we copy and move on
+ if (memcached_success(memcached_string_append_null(self)))
+ {
+ return memcached_string_c_copy(self);
+ }
+
+ char *value= self->string;
+
+ _init_string(self);
+
+ return value;
+}
+
char *memcached_string_value_mutable(const memcached_string_st *self)
{
return self->string;
LIBMEMCACHED_LOCAL
const char *memcached_string_value(const memcached_string_st *self);
+LIBMEMCACHED_LOCAL
+char *memcached_string_take_value(memcached_string_st *self);
+
LIBMEMCACHED_LOCAL
char *memcached_string_value_mutable(const memcached_string_st *self);
#define WATCHPOINT
#define WATCHPOINT_ERROR(A)
-#define WATCHPOINT_IFERROR(A)
+#define WATCHPOINT_IFERROR(__memcached_return_t) (void)(__memcached_return_t)
#define WATCHPOINT_STRING(A)
#define WATCHPOINT_NUMBER(A)
#define WATCHPOINT_LABELED_NUMBER(A,B)
#define WATCHPOINT_IF_LABELED_NUMBER(A,B,C)
#define WATCHPOINT_ERRNO(A)
#define WATCHPOINT_ASSERT_PRINT(A,B,C)
-#define WATCHPOINT_ASSERT(A)
+#define WATCHPOINT_ASSERT(A) (void)(A)
#define WATCHPOINT_ASSERT_INITIALIZED(A)
#define WATCHPOINT_SET(A)
if (libmemcached_util_flush("localhost", construct->port[x], NULL))
{
fprintf(stderr, "Found server on port %d, flushed it!\n", (int)construct->port[x]);
+ construct->is_used[x]= true;
} // If we can flush it, we will just use it
else
{
MEMCACHED_BINARY, construct->pid_file[x], construct->port[x], construct->port[x]);
}
- if (libmemcached_util_ping("localhost", construct->port[x], NULL))
- {
- fprintf(stderr, "Server on port %u already exists\n", construct->port[x]);
- }
- else
- {
- status= system(buffer);
- fprintf(stderr, "STARTING SERVER: %s status:%d\n", buffer, status);
- }
+ if (construct->is_used[x])
+ {
+ fprintf(stderr, "USING SERVER: %s\n", buffer);
+ }
+ else
+ {
+ if (libmemcached_util_ping("localhost", construct->port[x], NULL))
+ {
+ fprintf(stderr, "Server on port %u already exists\n", construct->port[x]);
+ }
+ else
+ {
+ status= system(buffer);
+ fprintf(stderr, "STARTING SERVER: %s status:%d\n", buffer, status);
+ }
+ }
int count;
size_t remaining_length= sizeof(server_string_buffer) - (size_t)(end_ptr -server_string_buffer);
for (uint32_t x= 0; x < construct->count; x++)
{
uint32_t counter= 3000; // Absurd, just to catch run away process
+
+ if (construct->is_used[x])
+ continue;
+
while (construct->pids[x] <= 0 && --counter)
{
FILE *file= fopen(construct->pid_file[x], "r");
}
fclose(file);
}
+
switch (errno)
{
default:
- fprintf(stderr, "%s -> fopen(%s)\n", construct->pid_file[x], strerror(errno));
+ fprintf(stderr, "Could not open pid file %s -> fopen(%s) -> %s:%d\n", construct->pid_file[x], strerror(errno), __FILE__, __LINE__);
abort();
+
case ENOENT:
case EINTR:
case EACCES:
+ case EINPROGRESS:
break;
+
case ENOTCONN:
continue;
}
{
for (uint32_t x= 0; x < construct->count; x++)
{
+ if (construct->is_used[x])
+ continue;
+
kill_file(construct->pid_file[x]);
}
char pid_file[SERVERS_TO_CREATE][FILENAME_MAX];
in_port_t port[SERVERS_TO_CREATE];
int pids[SERVERS_TO_CREATE];
+ bool is_used[SERVERS_TO_CREATE]; // Did we start it, or was it just sitting there?
};
void server_startup(server_startup_st *construct);
return "ok";
case TEST_FAILURE:
return "failed";
- case TEST_MEMORY_ALLOCATION_FAILURE:
- return "memory allocation";
+ case TEST_FATAL:
+ return "failed";
case TEST_SKIPPED:
return "skipped";
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ return "memory allocation";
case TEST_MAXIMUM_RETURN:
default:
fprintf(stderr, "Unknown return value\n");
char *wildcard= NULL;
world_st world;
collection_st *collection;
- collection_st *next;
void *world_ptr;
world_stats_st stats;
}
if (argc > 1)
+ {
collection_to_run= argv[1];
+ }
+ else if (getenv("TEST_COLLECTION"))
+ {
+ collection_to_run= getenv("TEST_COLLECTION");
+ }
+
+ if (collection_to_run)
+ printf("Only testing %s\n", collection_to_run);
if (argc == 3)
+ {
wildcard= argv[2];
+ }
- for (next= collection; next->name; next++)
+ for (collection_st *next= collection; next->name; next++)
{
test_return_t collection_rc= TEST_SUCCESS;
test_st *run;
case TEST_SUCCESS:
fprintf(stderr, "\n%s\n\n", next->name);
break;
+ case TEST_FATAL:
+ fprintf(stderr, "\n%s [ failed ]\n\n", next->name);
+ stats.collection_failed++;
+ goto cleanup;
case TEST_FAILURE:
fprintf(stderr, "\n%s [ failed ]\n\n", next->name);
stats.collection_failed++;
fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000);
stats.success++;
break;
+
+ case TEST_FATAL:
case TEST_FAILURE:
#if 0
push_failed_test(next->name, run->name);
stats.failed++;
failed= true;
break;
+
case TEST_SKIPPED:
stats.skipped++;
skipped= true;
break;
+
case TEST_MEMORY_ALLOCATION_FAILURE:
fprintf(stderr, "Exhausted memory, quitting\n");
abort();
+
case TEST_MAXIMUM_RETURN:
default:
assert(0); // Coding error.
if (rc != TEST_SUCCESS)
break;
}
+
+ // If we get a TEST_FATAL we move onto the next collection
+ if (return_code == TEST_FATAL)
+ {
+ break;
+ }
}
if (next->post && world.runner->post)
typedef struct collection_st collection_st;
typedef struct test_st test_st;
-typedef enum {
- TEST_SUCCESS= 0, /* Backwards compatibility */
+enum test_return_t {
+ TEST_SUCCESS, /* Backwards compatibility */
TEST_FAILURE,
TEST_MEMORY_ALLOCATION_FAILURE,
TEST_SKIPPED,
+ TEST_FATAL, // Collection should not be continued
TEST_MAXIMUM_RETURN /* Always add new error code before */
-} test_return_t;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum test_return_t test_return_t;
+
+#ifdef __cplusplus
+}
+#endif
+
typedef void *(*test_callback_create_fn)(test_return_t *error);
typedef test_return_t (*test_callback_fn)(void *);
} \
} while (0)
+#define test_skip(A,B) \
+do \
+{ \
+ if ((A) != (B)) \
+ { \
+ return TEST_SKIPPED; \
+ } \
+} while (0)
+
#define test_compare_got(A,B,C) \
do \
{ \
%{_includedir}/libmemcached/string.h
%{_includedir}/libmemcached/types.h
%{_includedir}/libmemcached/util.h
+%{_includedir}/libmemcached/util/flush.h
%{_includedir}/libmemcached/util/ping.h
%{_includedir}/libmemcached/util/pool.h
%{_includedir}/libmemcached/util/version.h
#include <sys/types.h>
#include <unistd.h>
+#include <iostream>
+
#include <libtest/server.h>
#include "clients/generator.h"
#define TEST_PORT_COUNT 7
in_port_t test_ports[TEST_PORT_COUNT];
-static memcached_return_t server_display_function(const memcached_st *ptr,
- const memcached_server_st *server,
- void *context)
+static memcached_return_t server_display_function(const memcached_st *ptr,
+ const memcached_server_st *server,
+ void *context)
{
/* Do Nothing */
size_t bigger= *((size_t *)(context));
{
test_ports[x]= (in_port_t)random() % 64000;
rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0);
- test_true(memcached_server_count(local_memc) == x + 1);
+ test_compare(memcached_server_count(local_memc), x +1);
#if 0 // Rewrite
test_true(memcached_server_list_count(memcached_server_list(local_memc)) == x+1);
#endif
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
callbacks[0]= server_display_function;
static test_return_t server_sort2_test(memcached_st *ptr)
{
size_t bigger= 0; /* Prime the value for the test_true in server_display_function */
- memcached_return_t rc;
memcached_server_fn callbacks[1];
memcached_st *local_memc;
memcached_server_instance_st instance;
local_memc= memcached_create(NULL);
test_true(local_memc);
- rc= memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1));
- rc= memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43043, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43043, 0));
instance= memcached_server_instance_by_position(local_memc, 0);
- test_true(memcached_server_port(instance) == 43043);
+ test_compare(43043, memcached_server_port(instance));
- rc= memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43042, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43042, 0));
instance= memcached_server_instance_by_position(local_memc, 0);
- test_true(memcached_server_port(instance) == 43042);
+ test_compare(43042, memcached_server_port(instance));
instance= memcached_server_instance_by_position(local_memc, 1);
- test_true(memcached_server_port(instance) == 43043);
+ test_compare(43043, memcached_server_port(instance));
callbacks[0]= server_display_function;
memcached_server_cursor(local_memc, callbacks, (void *)&bigger, 1);
{
size_t counter= 0; /* Prime the value for the test_true in server_display_function */
size_t bigger= 0; /* Prime the value for the test_true in server_display_function */
- memcached_return_t rc;
memcached_server_fn callbacks[1];
memcached_st *local_memc;
(void)ptr;
for (size_t x= 0; x < TEST_PORT_COUNT; x++)
{
test_ports[x]= (in_port_t)(random() % 64000);
- rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0);
- test_true(memcached_server_count(local_memc) == x+1);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0));
+ test_compare(memcached_server_count(local_memc), x +1);
#if 0 // Rewrite
test_true(memcached_server_list_count(memcached_server_list(local_memc)) == x+1);
#endif
- test_true(rc == MEMCACHED_SUCCESS);
}
callbacks[0]= server_display_unsort_function;
static test_return_t userdata_test(memcached_st *memc)
{
void* foo= NULL;
- test_true(memcached_set_user_data(memc, foo) == NULL);
+ test_false(memcached_set_user_data(memc, foo));
test_true(memcached_get_user_data(memc) == foo);
test_true(memcached_set_user_data(memc, NULL) == foo);
static test_return_t connection_test(memcached_st *memc)
{
- memcached_return_t rc;
-
- rc= memcached_server_add_with_weight(memc, "localhost", 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_with_weight(memc, "localhost", 0, 0));
return TEST_SUCCESS;
}
static test_return_t error_test(memcached_st *memc)
{
- uint32_t values[] = { 851992627U, 2337886783U, 646418395U, 4001849190U,
+ uint32_t values[] = { 851992627U, 2337886783U, 4109241422U, 4001849190U,
982370485U, 1263635348U, 4242906218U, 3829656100U,
1891735253U, 334139633U, 2257084983U, 3088286104U,
13199785U, 2542027183U, 1097051614U, 199566778U,
54481931U, 4186304426U, 1741088401U, 2979625118U,
4159057246U, 3425930182U, 2593724503U, 1868899624U,
1769812374U, 2302537950U, 1110330676U, 3365377466U,
- 1336171666U, 3021258493U, 3365377466U };
+ 1336171666U, 3021258493U, 2334992265U, 3365377466U };
// You have updated the memcache_error messages but not updated docs/tests.
for (int rc= int(MEMCACHED_SUCCESS); rc < int(MEMCACHED_MAXIMUM_RETURN); ++rc)
fprintf(stderr, "\n\nYou have updated memcached_return_t without updating the error_test\n");
fprintf(stderr, "%u, %s, (%u)\n\n", (uint32_t)rc, memcached_strerror(memc, memcached_return_t(rc)), hash_val);
}
- test_true(values[rc] == hash_val);
+ test_compare(values[rc], hash_val);
}
- test_true(MEMCACHED_MAXIMUM_RETURN == 46);
+ test_compare(MEMCACHED_MAXIMUM_RETURN, 47);
return TEST_SUCCESS;
}
memcached_literal_param("foo"),
memcached_literal_param("when we sanitize"),
time_t(0), (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ test_true_got(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
return TEST_SUCCESS;
}
uint32_t flags;
rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_set(memc, key, strlen(key),
in_value, strlen(in_value),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_append(memc, key, strlen(key),
" the", strlen(" the"),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_append(memc, key, strlen(key),
" people", strlen(" people"),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
out_value= memcached_get(memc, key, strlen(key),
&value_length, &flags, &rc);
- test_true(!memcmp(out_value, "we the people", strlen("we the people")));
- test_true(strlen("we the people") == value_length);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_memcmp(out_value, "we the people", strlen("we the people"));
+ test_compare(strlen("we the people"), value_length);
+ test_compare(MEMCACHED_SUCCESS, rc);
free(out_value);
return TEST_SUCCESS;
uint32_t x;
rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_set(memc,
key, strlen(key),
NULL, 0,
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
for (x= 0; store_list[x] ; x++)
{
key, strlen(key),
(char *)&store_list[x], sizeof(uint32_t),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
value= (uint32_t *)memcached_get(memc, key, strlen(key),
&value_length, &flags, &rc);
- test_true((value_length == (sizeof(uint32_t) * x)));
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(value_length, sizeof(uint32_t) * x);
+ test_compare(MEMCACHED_SUCCESS, rc);
for (uint32_t counter= x, *ptr= value; counter; counter--)
{
- test_true(*ptr == store_list[x - counter]);
+ test_compare(*ptr, store_list[x - counter]);
ptr++;
}
free(value);
size_t key_length[]= {5, 3, 4};
const char *value= "we the people";
size_t value_length= strlen("we the people");
- unsigned int x;
memcached_result_st results_obj;
memcached_result_st *results;
unsigned int set= 1;
- rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, set);
- for (x= 0; x < 3; x++)
+ for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
rc= memcached_mget(memc, keys, key_length, 3);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
test_true(results->item_cas);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_result_cas(results));
- test_true(!memcmp(value, "we the people", strlen("we the people")));
- test_true(strlen("we the people") == value_length);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_memcmp(value, "we the people", strlen("we the people"));
+ test_compare(strlen("we the people"), value_length);
+ test_compare(MEMCACHED_SUCCESS, rc);
memcached_result_free(&results_obj);
unsigned int set= 1;
rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, set);
rc= memcached_set(memc, key, strlen(key),
value, strlen(value),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_mget(memc, keys, keylengths, 1);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_result_cas(results));
- test_true(!memcmp(value, memcached_result_value(results), value_length));
- test_true(strlen(memcached_result_value(results)) == value_length);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_memcmp(value, memcached_result_value(results), value_length);
+ test_compare(strlen(memcached_result_value(results)), value_length);
+ test_compare(MEMCACHED_SUCCESS, rc);
uint64_t cas = memcached_result_cas(results);
#if 0
#endif
rc= memcached_cas(memc, key, key_length, value2, value2_length, 0, 0, cas);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
/*
* The item will have a new cas value, so try to set it again with the old
* value. This should fail!
*/
rc= memcached_cas(memc, key, key_length, value2, value2_length, 0, 0, cas);
- test_true(rc == MEMCACHED_DATA_EXISTS);
+ test_compare(MEMCACHED_DATA_EXISTS, rc);
memcached_result_free(&results_obj);
uint32_t flags;
rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_set(memc, key, strlen(key),
value, strlen(value),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_prepend(memc, key, strlen(key),
"the ", strlen("the "),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_prepend(memc, key, strlen(key),
"we ", strlen("we "),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
out_value= memcached_get(memc, key, strlen(key),
&value_length, &flags, &rc);
- test_true(!memcmp(out_value, "we the people", strlen("we the people")));
- test_true(strlen("we the people") == value_length);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_memcmp(out_value, "we the people", strlen("we the people"));
+ test_compare(strlen("we the people"), value_length);
+ test_compare(MEMCACHED_SUCCESS, rc);
free(out_value);
return TEST_SUCCESS;
(time_t)0, (uint32_t)0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
- rc= memcached_replace(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_replace(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0));
return TEST_SUCCESS;
}
static test_return_t flush_test(memcached_st *memc)
{
- memcached_return_t rc;
-
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_flush(memc, 0);
- test_compare(rc, MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
test_compare(query_id +1, memcached_query_id(memc));
return TEST_SUCCESS;
test_true(memc_clone);
query_id= memcached_query_id(memc_clone);
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set));
test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
/* All keys are valid in the binary protocol (except for length) */
- if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 0)
+ if (not memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
{
query_id= memcached_query_id(memc_clone);
string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+ test_compare(0, string_length);
+ test_false(string);
set= 0;
query_id= memcached_query_id(memc_clone);
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set));
test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
- test_true(rc == MEMCACHED_SUCCESS);
string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(0, string_length);
+ test_false(string);
/* Test multi key for bad keys */
const char *keys[] = { "GoodKey", "Bad Key", "NotMine" };
size_t key_lengths[] = { 7, 7, 7 };
set= 1;
query_id= memcached_query_id(memc_clone);
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set));
test_compare(query_id, memcached_query_id(memc_clone));
query_id= memcached_query_id(memc_clone);
- rc= memcached_mget(memc_clone, keys, key_lengths, 3);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED,
+ memcached_mget(memc_clone, keys, key_lengths, 3));
test_compare(query_id +1, memcached_query_id(memc_clone));
query_id= memcached_query_id(memc_clone);
- rc= memcached_mget_by_key(memc_clone, "foo daddy", 9, keys, key_lengths, 1);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED,
+ memcached_mget_by_key(memc_clone, "foo daddy", 9, keys, key_lengths, 1));
test_compare(query_id +1, memcached_query_id(memc_clone));
max_keylen= 250;
memcached server is updated to allow max size length of the keys in the
binary protocol
*/
- rc= memcached_callback_set(memc_clone, MEMCACHED_CALLBACK_PREFIX_KEY, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_callback_set(memc_clone, MEMCACHED_CALLBACK_PREFIX_KEY, NULL));
char *longkey= (char *)malloc(max_keylen + 1);
- if (longkey != NULL)
+ if (longkey)
{
memset(longkey, 'a', max_keylen + 1);
string= memcached_get(memc_clone, longkey, max_keylen,
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare(MEMCACHED_NOTFOUND, rc);
+ test_compare(0, string_length);
+ test_false(string);
string= memcached_get(memc_clone, longkey, max_keylen + 1,
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+ test_compare(0, string_length);
+ test_false(string);
free(longkey);
}
/* Make sure zero length keys are marked as bad */
set= 1;
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set));
string= memcached_get(memc_clone, key, 0,
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+ test_compare(0, string_length);
+ test_false(string);
memcached_free(memc_clone);
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(MEMCACHED_NOTFOUND, rc);
test_false(string_length);
test_false(string);
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, *(void **)&cb);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(string_length == strlen(READ_THROUGH_VALUE));
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(string_length, sizeof(READ_THROUGH_VALUE) -1);
+ test_true(string[sizeof(READ_THROUGH_VALUE) -1] == 0);
test_strcmp(READ_THROUGH_VALUE, string);
free(string);
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(string_length == strlen(READ_THROUGH_VALUE));
- test_true(!strcmp(READ_THROUGH_VALUE, string));
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(string);
+ test_compare(string_length, sizeof(READ_THROUGH_VALUE) -1);
+ test_true(string[sizeof(READ_THROUGH_VALUE) -1] == 0);
+ test_strcmp(READ_THROUGH_VALUE, string);
free(string);
return TEST_SUCCESS;
}
-static memcached_return_t delete_trigger(memcached_st *ptr,
- const char *key,
- size_t key_length)
+static memcached_return_t delete_trigger(memcached_st *,
+ const char *key,
+ size_t key_length)
{
- (void)ptr;(void)key_length;
assert(key);
+ assert(key_length);
return MEMCACHED_SUCCESS;
}
callback= (memcached_trigger_delete_key_fn)delete_trigger;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
return TEST_SUCCESS;
}
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
test_false(string_length);
test_false(string);
static test_return_t get_test2(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
- char *string;
- size_t string_length;
- uint32_t flags;
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_set(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
test_compare(query_id +1, memcached_query_id(memc));
query_id= memcached_query_id(memc);
- string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
+ test_true(query_id);
+
+ uint32_t flags;
+ size_t string_length;
+ char *string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
test_compare(query_id +1, memcached_query_id(memc));
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_SUCCESS, memcached_last_error(memc), memcached_last_error_message(memc));
test_true(string);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(string_length == strlen(value));
+ test_compare(strlen(value), string_length);
test_memcmp(string, value, string_length);
free(string);
static test_return_t set_test2(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
const char *value= "train in the brain";
size_t value_length= strlen(value);
- unsigned int x;
- for (x= 0; x < 10; x++)
+ for (uint32_t x= 0; x < 10; x++)
{
- rc= memcached_set(memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
}
return TEST_SUCCESS;
static test_return_t set_test3(memcached_st *memc)
{
- memcached_return_t rc;
- char *value;
size_t value_length= 8191;
- value = (char*)malloc(value_length);
+ char *value= (char*)malloc(value_length);
test_true(value);
for (uint32_t x= 0; x < value_length; x++)
+ {
value[x] = (char) (x % 127);
+ }
/* The dump test relies on there being at least 32 items in memcached */
for (uint32_t x= 0; x < 32; x++)
snprintf(key, sizeof(key), "foo%u", x);
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_set(memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint32_t)0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
test_compare(query_id +1, memcached_query_id(memc));
}
static test_return_t get_test3(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
- char *value;
size_t value_length= 8191;
- char *string;
- size_t string_length;
- uint32_t flags;
- uint32_t x;
- value = (char*)malloc(value_length);
+ char *value= (char*)malloc(value_length);
test_true(value);
- for (x= 0; x < value_length; x++)
+ for (uint32_t x= 0; x < value_length; x++)
+ {
value[x] = (char) (x % 127);
+ }
+ memcached_return_t rc;
rc= memcached_set(memc, key, strlen(key),
value, value_length,
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
+ size_t string_length;
+ uint32_t flags;
+ char *string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(string);
- test_true(string_length == value_length);
- test_true(!memcmp(string, value, string_length));
+ test_compare(string_length, value_length);
+ test_memcmp(string, value, string_length);
free(string);
free(value);
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(string);
- test_true(string_length == value_length);
- test_true(!memcmp(string, value, string_length));
+ test_compare(string_length, value_length);
+ test_memcmp(string, value, string_length);
free(string);
}
memcached_return_t rc= memcached_set(memc, keys[0], lengths[0],
keys[0], lengths[0], 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_mget(memc, keys, lengths, 2);
memcached_result_st results_obj;
/* Don't read out the second result, but issue a set instead.. */
rc= memcached_set(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
char *val= memcached_get_by_key(memc, keys[0], lengths[0], "yek", 3,
&rlen, &flags, &rc);
- test_true(val == NULL);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_false(val);
+ test_compare(MEMCACHED_NOTFOUND, rc);
val= memcached_get(memc, keys[0], lengths[0], &rlen, &flags, &rc);
- test_true(val != NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_true(val);
+ test_compare(MEMCACHED_SUCCESS, rc);
free(val);
return TEST_SUCCESS;
{
rc= memcached_set(memc, keys[i], lengths[i], values[i], strlen(values[i]),
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
char *string;
// retrieve both via mget
rc= memcached_mget(memc, keys, lengths, 2);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
char key[MEMCACHED_MAX_KEY];
size_t key_length;
{
string= memcached_fetch(memc, key, &key_length, &string_length,
&flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
int val = 0;
if (key_length == 4)
val= 1;
- test_true(string_length == strlen(values[val]));
+ test_compare(string_length, strlen(values[val]));
test_true(strncmp(values[val], string, string_length) == 0);
free(string);
}
// this should indicate end
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
- test_true(rc == MEMCACHED_END);
+ test_compare(MEMCACHED_END, rc);
// now get just one
rc= memcached_mget(memc, keys, lengths, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
- test_true(key_length == lengths[0]);
+ test_compare(key_length, lengths[0]);
test_true(strncmp(keys[0], key, key_length) == 0);
- test_true(string_length == strlen(values[0]));
+ test_compare(string_length, strlen(values[0]));
test_true(strncmp(values[0], string, string_length) == 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
free(string);
// this should indicate end
rc= memcached_increment(memc, key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 1);
rc= memcached_increment(memc, key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 2);
return TEST_SUCCESS;
rc= memcached_increment_with_initial(memc, key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == initial);
rc= memcached_increment_with_initial(memc, key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == (initial + 1));
}
return TEST_SUCCESS;
rc= memcached_decrement(memc, key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 2);
rc= memcached_decrement(memc, key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 1);
return TEST_SUCCESS;
rc= memcached_decrement_with_initial(memc, key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == initial);
rc= memcached_decrement_with_initial(memc, key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == (initial - 1));
}
return TEST_SUCCESS;
rc= memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 1);
rc= memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 2);
return TEST_SUCCESS;
rc= memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == initial);
rc= memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
key, strlen(key),
1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == (initial + 1));
}
return TEST_SUCCESS;
rc= memcached_decrement_by_key(memc, master_key, strlen(master_key),
key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 2);
rc= memcached_decrement_by_key(memc, master_key, strlen(master_key),
key, strlen(key),
1, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(new_number == 1);
return TEST_SUCCESS;
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0)
{
uint64_t new_number;
- memcached_return_t rc;
const char *master_key= "foo";
const char *key= "number";
uint64_t initial= 3;
- rc= memcached_decrement_with_initial_by_key(memc, master_key, strlen(master_key),
- key, strlen(key),
- 1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(new_number == initial);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_decrement_with_initial_by_key(memc, master_key, strlen(master_key),
+ key, strlen(key),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, initial);
- rc= memcached_decrement_with_initial_by_key(memc, master_key, strlen(master_key),
- key, strlen(key),
- 1, initial, 0, &new_number);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(new_number == (initial - 1));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_decrement_with_initial_by_key(memc, master_key, strlen(master_key),
+ key, strlen(key),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, (initial - 1));
}
return TEST_SUCCESS;
}
static test_return_t mget_result_test(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
- unsigned int x;
memcached_result_st results_obj;
memcached_result_st *results;
test_true(&results_obj == results);
/* We need to empty the server before continueing test */
- rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)) != NULL)
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
{
test_true(results);
}
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)) != NULL)
- test_true(!results);
- test_true(rc == MEMCACHED_END);
+ while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(false); /* We should never see a value returned */ };
+ test_false(results);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
- for (x= 0; x < 3; x++)
+ for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
{
test_true(results);
test_true(&results_obj == results);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(memcached_result_key_length(results) == memcached_result_length(results));
- test_true(!memcmp(memcached_result_key_value(results),
- memcached_result_value(results),
- memcached_result_length(results)));
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(memcached_result_key_length(results), memcached_result_length(results));
+ test_memcmp(memcached_result_key_value(results),
+ memcached_result_value(results),
+ memcached_result_length(results));
}
memcached_result_free(&results_obj);
static test_return_t mget_result_alloc_test(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
- unsigned int x;
memcached_result_st *results;
/* We need to empty the server before continueing test */
- rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
- while ((results= memcached_fetch_result(memc, NULL, &rc)) != NULL)
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, NULL, &rc)))
{
test_true(results);
}
- test_true(!results);
- test_true(rc == MEMCACHED_END);
+ test_false(results);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
- for (x= 0; x < 3; x++)
+ for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
- x= 0;
+ uint32_t x= 0;
while ((results= memcached_fetch_result(memc, NULL, &rc)))
{
test_true(results);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_result_key_length(results) == memcached_result_length(results));
- test_true(!memcmp(memcached_result_key_value(results),
- memcached_result_value(results),
- memcached_result_length(results)));
+ test_memcmp(memcached_result_key_value(results),
+ memcached_result_value(results),
+ memcached_result_length(results));
memcached_result_free(results);
x++;
}
}
/* Count the results */
-static memcached_return_t callback_counter(const memcached_st *ptr,
- memcached_result_st *result,
- void *context)
+static memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context)
{
- (void)ptr; (void)result;
size_t *counter= (size_t *)context;
*counter= *counter + 1;
static test_return_t mget_result_function(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
- unsigned int x;
size_t counter;
memcached_execute_fn callbacks[1];
/* We need to empty the server before continueing test */
- rc= memcached_flush(memc, 0);
- for (x= 0; x < 3; x++)
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
+ for (uint32_t x= 0; x < 3; x++)
{
- rc= memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- (time_t)50, (uint32_t)9);
+ memcached_return_t rc= memcached_set(memc, keys[x], key_length[x],
+ keys[x], key_length[x],
+ (time_t)50, (uint32_t)9);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
callbacks[0]= &callback_counter;
counter= 0;
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
- test_true(counter == 3);
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1),
+ memcached_strerror(NULL, rc));
+
+ test_compare(counter, 3);
return TEST_SUCCESS;
}
static test_return_t mget_test(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
- unsigned int x;
- uint32_t flags;
char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
size_t return_value_length;
/* We need to empty the server before continueing test */
- rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
+ uint32_t flags;
+ memcached_return_t rc;
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)) != NULL)
+ &return_value_length, &flags, &rc)))
{
test_true(return_value);
}
- test_true(!return_value);
- test_true(return_value_length == 0);
- test_true(rc == MEMCACHED_END);
+ test_false(return_value);
+ test_compare(0, return_value_length);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
- for (x= 0; x < 3; x++)
+ for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
-
- x= 0;
+ uint32_t x= 0;
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
&return_value_length, &flags, &rc)))
{
test_true(return_value);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(return_key_length == return_value_length);
- test_true(!memcmp(return_value, return_key, return_value_length));
+ test_memcmp(return_value, return_key, return_value_length);
free(return_value);
x++;
}
rc= memcached_mget_execute(memc, (const char**)keys, key_length,
max_keys, callbacks, &counter, 1);
- if (rc == MEMCACHED_SUCCESS)
+ if (memcached_success(rc))
{
test_true(binary);
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
- test_true(rc == MEMCACHED_END);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
test_compare(query_id, memcached_query_id(memc));
/* Verify that we got all of the items */
static test_return_t key_setup(memcached_st *memc)
{
- (void)memc;
-
- if (pre_binary(memc) != TEST_SUCCESS)
- return TEST_SKIPPED;
+ test_skip(TEST_SUCCESS, pre_binary(memc));
global_pairs= pairs_generate(REGRESSION_BINARY_VS_BLOCK_COUNT, 0);
memcached_return_t rc;
stat_list= memcached_stat_get_keys(memc, &memc_stat, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
for (ptr= stat_list; *ptr; ptr++)
test_true(*ptr);
version_string= memcached_lib_version();
- test_true(!strcmp(version_string, LIBMEMCACHED_VERSION_STRING));
+ test_strcmp(version_string, LIBMEMCACHED_VERSION_STRING);
return TEST_SUCCESS;
}
static test_return_t get_stats(memcached_st *memc)
{
- char **stat_list;
- char **ptr;
memcached_return_t rc;
- memcached_stat_st *memc_stat;
-
- memc_stat= memcached_stat(memc, NULL, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(rc == MEMCACHED_SUCCESS);
+ memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memc_stat);
for (uint32_t x= 0; x < memcached_server_count(memc); x++)
{
- stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- for (ptr= stat_list; *ptr; ptr++);
+ char **stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ for (char **ptr= stat_list; *ptr; ptr++);
free(stat_list);
}
snprintf(buffer, SMALL_STRING_LEN, "%u.example.com", 400+x);
servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
&rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(x == memcached_server_list_count(servers));
}
rc= memcached_server_push(memc, servers);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_server_push(memc, servers);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
memcached_server_list_free(servers);
return TEST_SUCCESS;
}
+static test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc)
+{
+ memcached_return_t rc;
+ const char *key= "not_found";
+ size_t key_len= strlen(key);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, &key, &key_len, 1));
+
+ memcached_result_st *result= NULL;
+ result= memcached_fetch_result(memc, result, &rc);
+ test_false(result);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+
+ memcached_result_free(result);
+
+ return TEST_SUCCESS;
+}
+
static memcached_return_t clone_test_callback(memcached_st *parent, memcached_st *memc_clone)
{
(void)parent;(void)memc_clone;
memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_USER_DATA, &x);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_ptr= (int *)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc);
test_true(*test_ptr == x);
}
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION,
clone_cb_ptr);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc);
test_true(temp_function == clone_cb_ptr);
}
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION,
cleanup_cb_ptr);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc);
test_true(temp_function == cleanup_cb_ptr);
}
return TEST_SUCCESS;
}
-static test_return_t fetch_all_results(memcached_st *memc, size_t *keys_returned)
+static test_return_t fetch_all_results(memcached_st *memc, size_t &keys_returned, const memcached_return_t expect)
{
- memcached_return_t rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc;
char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
char *return_value;
size_t return_value_length;
uint32_t flags;
- *keys_returned= 0;
-
+ keys_returned= 0;
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
&return_value_length, &flags, &rc)))
{
test_true(return_value);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
free(return_value);
- *keys_returned= *keys_returned +1;
+ keys_returned+= 1;
}
- test_true_got(rc == MEMCACHED_END || memcached_success(rc), memcached_strerror(NULL, rc));
+ if (memcached_success(expect) and memcached_success(rc))
+ {
+ return TEST_SUCCESS;
+ }
+ else if (expect == rc)
+ {
+ return TEST_SUCCESS;
+ }
+ fprintf(stderr, "\n%s:%u %s(#%lu)\n", __FILE__, __LINE__, memcached_strerror(NULL, rc), (unsigned long)(keys_returned));
- return TEST_SUCCESS;
+ return TEST_FAILURE;
}
/* Test case provided by Cal Haldenbrand */
+#define HALDENBRAND_KEY_COUNT 3000 // * 1024576
+#define HALDENBRAND_FLAG_KEY 99 // * 1024576
static test_return_t user_supplied_bug1(memcached_st *memc)
{
- unsigned int setter= 1;
-
- unsigned long long total= 0;
- uint32_t size= 0;
- char key[10];
- char randomstuff[6 * 1024];
- memcached_return_t rc;
-
- memset(randomstuff, 0, 6 * 1024);
-
/* We just keep looking at the same values over and over */
srandom(10);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter);
+ unsigned int setter= 1;
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter));
/* add key */
+ unsigned long long total= 0;
for (uint32_t x= 0 ; total < 20 * 1024576 ; x++ )
{
- unsigned int j= 0;
-
- size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
+ uint32_t size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
+ char randomstuff[6 * 1024];
memset(randomstuff, 0, 6 * 1024);
test_true(size < 6 * 1024); /* Being safe here */
- for (j= 0 ; j < size ;j++)
+ for (uint32_t j= 0 ; j < size ;j++)
+ {
randomstuff[j] = (signed char) ((rand() % 26) + 97);
+ }
- total += size;
- snprintf(key, sizeof(key), "%u", x);
- rc = memcached_set(memc, key, strlen(key),
- randomstuff, strlen(randomstuff), 10, 0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
- /* If we fail, lets try again */
- if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED)
- rc = memcached_set(memc, key, strlen(key),
- randomstuff, strlen(randomstuff), 10, 0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ total+= size;
+ char key[22];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_set(memc, key, key_length, randomstuff, strlen(randomstuff), time_t(0), HALDENBRAND_FLAG_KEY),
+ memcached_strerror(NULL, rc));
}
+ test_true(total > HALDENBRAND_KEY_COUNT);
return TEST_SUCCESS;
}
/* Test case provided by Cal Haldenbrand */
static test_return_t user_supplied_bug2(memcached_st *memc)
{
- unsigned int setter;
- size_t total= 0;
+ unsigned int setter= 1;
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter));
- setter= 1;
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter);
#ifdef NOT_YET
setter = 20 * 1024576;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, setter);
for (x= 0, errors= 0; total < 20 * 1024576 ; x++)
#endif
- for (uint32_t x= 0, errors= 0; total < 24576 ; x++)
+ size_t total_value_length= 0;
+ for (uint32_t x= 0, errors= 0; total_value_length < 24576 ; x++)
{
- memcached_return_t rc= MEMCACHED_SUCCESS;
- char buffer[SMALL_STRING_LEN];
uint32_t flags= 0;
size_t val_len= 0;
- char *getval;
- memset(buffer, 0, SMALL_STRING_LEN);
+ char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
- snprintf(buffer, sizeof(buffer), "%u", x);
- getval= memcached_get(memc, buffer, strlen(buffer),
- &val_len, &flags, &rc);
- if (rc != MEMCACHED_SUCCESS)
+ memcached_return_t rc;
+ char *getval= memcached_get(memc, key, key_length, &val_len, &flags, &rc);
+ if (memcached_failed(rc))
{
if (rc == MEMCACHED_NOTFOUND)
+ {
errors++;
+ }
else
{
test_true(rc);
continue;
}
- total+= val_len;
+ test_compare(HALDENBRAND_FLAG_KEY, flags);
+
+ total_value_length+= val_len;
errors= 0;
free(getval);
}
}
/* Do a large mget() over all the keys we think exist */
-#define KEY_COUNT 3000 // * 1024576
static test_return_t user_supplied_bug3(memcached_st *memc)
{
- memcached_return_t rc;
- unsigned int setter;
- unsigned int x;
- char **keys;
- size_t key_lengths[KEY_COUNT];
-
- setter= 1;
+ unsigned int setter= 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter);
#ifdef NOT_YET
getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
#endif
- keys= static_cast<char **>(calloc(KEY_COUNT, sizeof(char *)));
+ size_t key_lengths[HALDENBRAND_KEY_COUNT];
+ char **keys= static_cast<char **>(calloc(HALDENBRAND_KEY_COUNT, sizeof(char *)));
test_true(keys);
- for (x= 0; x < KEY_COUNT; x++)
+ for (uint32_t x= 0; x < HALDENBRAND_KEY_COUNT; x++)
{
- char buffer[30];
-
- snprintf(buffer, 30, "%u", x);
- keys[x]= strdup(buffer);
- key_lengths[x]= strlen(keys[x]);
+ char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
+ keys[x]= strdup(key);
+ test_true(keys[x]);
+ key_lengths[x]= key_length;
+ test_compare(key_length, strlen(keys[x]));
}
- rc= memcached_mget(memc, (const char **)keys, key_lengths, KEY_COUNT);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, (const char **)keys, key_lengths, HALDENBRAND_KEY_COUNT));
+ test_return_t foo;
size_t keys_returned;
- test_true(fetch_all_results(memc, &keys_returned) == TEST_SUCCESS);
+ test_compare_got(TEST_SUCCESS, foo= fetch_all_results(memc, keys_returned, MEMCACHED_SUCCESS), test_strerror(foo));
+ test_compare(HALDENBRAND_KEY_COUNT, keys_returned);
- for (x= 0; x < KEY_COUNT; x++)
+ for (uint32_t x= 0; x < HALDENBRAND_KEY_COUNT; x++)
+ {
free(keys[x]);
+ }
free(keys);
return TEST_SUCCESS;
/* Make sure we behave properly if server list has no values */
static test_return_t user_supplied_bug4(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
- unsigned int x;
- uint32_t flags;
- char return_key[MEMCACHED_MAX_KEY];
- size_t return_key_length;
- char *return_value;
- size_t return_value_length;
/* Here we free everything before running a bunch of mget tests */
memcached_servers_reset(memc);
/* We need to empty the server before continueing test */
- rc= memcached_flush(memc, 0);
- test_compare(rc, MEMCACHED_NO_SERVERS);
+ test_compare(MEMCACHED_NO_SERVERS,
+ memcached_flush(memc, 0));
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_NO_SERVERS);
+ test_compare(MEMCACHED_NO_SERVERS,
+ memcached_mget(memc, keys, key_length, 3));
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)) != NULL)
- {
- test_true(return_value);
- }
- test_false(return_value);
- test_true(return_value_length == 0);
- test_true(rc == MEMCACHED_NO_SERVERS);
+ size_t keys_returned;
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, MEMCACHED_NOTFOUND));
+ test_compare(0, keys_returned);
- for (x= 0; x < 3; x++)
+ for (uint32_t x= 0; x < 3; x++)
{
- rc= memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- (time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_NO_SERVERS);
+ test_compare(MEMCACHED_NO_SERVERS,
+ memcached_set(memc, keys[x], key_length[x],
+ keys[x], key_length[x],
+ (time_t)50, (uint32_t)9));
}
- rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_NO_SERVERS);
+ test_compare(MEMCACHED_NO_SERVERS,
+ memcached_mget(memc, keys, key_length, 3));
- x= 0;
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)))
{
- test_true(return_value);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(return_key_length == return_value_length);
- test_memcmp(return_value, return_key, return_value_length);
- free(return_value);
- x++;
+ char *return_value;
+ char return_key[MEMCACHED_MAX_KEY];
+ memcached_return_t rc;
+ size_t return_key_length;
+ size_t return_value_length;
+ uint32_t flags;
+ uint32_t x= 0;
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
+ &return_value_length, &flags, &rc)))
+ {
+ test_true(return_value);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(return_key_length == return_value_length);
+ test_memcmp(return_value, return_key, return_value_length);
+ free(return_value);
+ x++;
+ }
}
return TEST_SUCCESS;
#define VALUE_SIZE_BUG5 1048064
static test_return_t user_supplied_bug5(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
- char return_key[MEMCACHED_MAX_KEY];
- size_t return_key_length;
char *value;
size_t value_length;
uint32_t flags;
- unsigned int count;
- unsigned int x;
char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5];
- for (x= 0; x < VALUE_SIZE_BUG5; x++)
+ for (uint32_t x= 0; x < VALUE_SIZE_BUG5; x++)
+ {
insert_data[x]= (signed char)rand();
+ }
- memcached_flush(memc, 0);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
+
+ memcached_return_t rc;
value= memcached_get(memc, keys[0], key_length[0],
&value_length, &flags, &rc);
- test_true(value == NULL);
- rc= memcached_mget(memc, keys, key_length, 4);
+ test_false(value);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 4));
- count= 0;
- while ((value= memcached_fetch(memc, return_key, &return_key_length,
- &value_length, &flags, &rc)))
- count++;
- test_true(count == 0);
+ size_t count;
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, count, MEMCACHED_NOTFOUND));
+ test_compare(0, count);
- for (x= 0; x < 4; x++)
+ for (uint32_t x= 0; x < 4; x++)
{
- rc= memcached_set(memc, keys[x], key_length[x],
- insert_data, VALUE_SIZE_BUG5,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, keys[x], key_length[x],
+ insert_data, VALUE_SIZE_BUG5,
+ (time_t)0, (uint32_t)0));
}
- for (x= 0; x < 10; x++)
+ for (uint32_t x= 0; x < 10; x++)
{
value= memcached_get(memc, keys[0], key_length[0],
&value_length, &flags, &rc);
+ test_compare(rc, MEMCACHED_SUCCESS);
test_true(value);
free(value);
- rc= memcached_mget(memc, keys, key_length, 4);
- count= 0;
- while ((value= memcached_fetch(memc, return_key, &return_key_length,
- &value_length, &flags, &rc)))
- {
- count++;
- free(value);
- }
- test_true(count == 4);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 4));
+
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, count, MEMCACHED_SUCCESS));
+ test_compare(4, count);
}
delete [] insert_data;
static test_return_t user_supplied_bug6(memcached_st *memc)
{
- memcached_return_t rc;
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
char return_key[MEMCACHED_MAX_KEY];
char *value;
size_t value_length;
uint32_t flags;
- unsigned int count;
- unsigned int x;
char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5];
- for (x= 0; x < VALUE_SIZE_BUG5; x++)
+ for (uint32_t x= 0; x < VALUE_SIZE_BUG5; x++)
+ {
insert_data[x]= (signed char)rand();
+ }
- memcached_flush(memc, 0);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_flush(memc, 0));
+
+ memcached_return_t rc;
value= memcached_get(memc, keys[0], key_length[0],
&value_length, &flags, &rc);
- test_true(value == NULL);
- test_true(rc == MEMCACHED_NOTFOUND);
- rc= memcached_mget(memc, keys, key_length, 4);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_false(value);
+ test_compare(MEMCACHED_NOTFOUND, rc);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 4));
- count= 0;
+ uint32_t count= 0;
while ((value= memcached_fetch(memc, return_key, &return_key_length,
&value_length, &flags, &rc)))
+ {
count++;
- test_true(count == 0);
- test_true(rc == MEMCACHED_END);
+ }
+ test_compare(0, count);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
- for (x= 0; x < 4; x++)
+ for (uint32_t x= 0; x < 4; x++)
{
- rc= memcached_set(memc, keys[x], key_length[x],
- insert_data, VALUE_SIZE_BUG5,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, keys[x], key_length[x],
+ insert_data, VALUE_SIZE_BUG5,
+ (time_t)0, (uint32_t)0));
}
- for (x= 0; x < 2; x++)
+ for (uint32_t x= 0; x < 2; x++)
{
value= memcached_get(memc, keys[0], key_length[0],
&value_length, &flags, &rc);
test_true(value);
free(value);
- rc= memcached_mget(memc, keys, key_length, 4);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 4));
count= 3;
/* We test for purge of partial complete fetches */
for (count= 3; count; count--)
{
value= memcached_fetch(memc, return_key, &return_key_length,
&value_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(!(memcmp(value, insert_data, value_length)));
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_memcmp(value, insert_data, value_length);
test_true(value_length);
free(value);
}
return TEST_SUCCESS;
}
-static test_return_t user_supplied_bug8(memcached_st *memc)
+static test_return_t user_supplied_bug8(memcached_st *)
{
memcached_return_t rc;
memcached_st *mine;
memcached_server_st *servers;
const char *server_list= "memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214";
- (void)memc;
servers= memcached_servers_parse(server_list);
test_true(servers);
mine= memcached_create(NULL);
rc= memcached_server_push(mine, servers);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
memcached_server_list_free(servers);
test_true(mine);
memcached_return_t rc= memcached_set(memc, keys, key_length,
insert_data, VALUE_SIZE_BUG5,
(time_t)0, flags);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
flags= 0;
value= memcached_get(memc, keys, key_length,
memcached_return_t rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
memcached_return_t rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
/* We need to empty the server before continueing test */
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
static test_return_t user_supplied_bug10(memcached_st *memc)
{
const char *key= "foo";
- char *value;
size_t value_length= 512;
- unsigned int x;
size_t key_len= 3;
unsigned int set= 1;
memcached_st *mclone= memcached_clone(NULL, memc);
- int32_t timeout;
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
- timeout= 2;
- memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
- (uint64_t)timeout);
+ int32_t timeout= 0;
+ memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, (uint64_t)timeout);
- value = (char*)malloc(value_length * sizeof(char));
+ char *value= (char*)malloc(value_length * sizeof(char));
- for (x= 0; x < value_length; x++)
+ for (unsigned int x= 0; x < value_length; x++)
+ {
value[x]= (char) (x % 127);
+ }
- for (x= 1; x <= 100000; ++x)
+ for (unsigned int x= 1; x <= 100000; ++x)
{
memcached_return_t rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_WRITE_FAILURE ||
- rc == MEMCACHED_BUFFERED || rc == MEMCACHED_TIMEOUT);
+ test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_BUFFERED or rc == MEMCACHED_TIMEOUT or rc == MEMCACHED_CONNECTION_FAILURE,
+ memcached_strerror(NULL, rc));
- if (rc == MEMCACHED_WRITE_FAILURE || rc == MEMCACHED_TIMEOUT)
+ if (rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_TIMEOUT)
+ {
x--;
+ }
}
free(value);
static test_return_t user_supplied_bug11(memcached_st *memc)
{
const char *key= "foo";
- char *value;
size_t value_length= 512;
- unsigned int x;
size_t key_len= 3;
- memcached_return_t rc;
unsigned int set= 1;
- int32_t timeout;
memcached_st *mclone= memcached_clone(NULL, memc);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
- timeout= -1;
- memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
- (size_t)timeout);
+ int32_t timeout= -1;
+ memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, (size_t)timeout);
timeout= (int32_t)memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
test_true(timeout == -1);
- value = (char*)malloc(value_length * sizeof(char));
+ char *value= (char*)malloc(value_length * sizeof(char));
- for (x= 0; x < value_length; x++)
+ for (unsigned int x= 0; x < value_length; x++)
+ {
value[x]= (char) (x % 127);
+ }
- for (x= 1; x <= 100000; ++x)
+ for (unsigned int x= 1; x <= 100000; ++x)
{
- rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
+ memcached_return_t rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
+ (void)rc;
}
free(value);
value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
&value_length, &flags, &rc);
test_true(value == NULL);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(MEMCACHED_NOTFOUND, rc);
rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"),
1, &number_value);
/* The binary protocol will set the key if it doesn't exist */
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1)
{
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
else
{
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(MEMCACHED_NOTFOUND, rc);
}
rc= memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0);
value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
&value_length, &flags, &rc);
test_true(value);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
free(value);
rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"),
1, &number_value);
test_true(number_value == 2);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
return TEST_SUCCESS;
}
memset(overflow, 'x', testSize);
rc= memcached_set(memc, key, strlen(key),
overflow, testSize, 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
delete [] overflow;
}
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(string_length == current_length);
- test_true(!memcmp(string, value, string_length));
+ test_memcmp(string, value, string_length);
free(string);
}
uint32_t x;
memcached_return_t rc;
const char *key= "mykey";
- char *value;
size_t length;
uint32_t flags;
NULL, 0,
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
- value= memcached_get(memc, key, strlen(key),
- &length, &flags, &rc);
+ char *value= memcached_get(memc, key, strlen(key),
+ &length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(value == NULL);
- test_true(length == 0);
- test_true(flags == 0);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_false(value);
+ test_false(length);
+ test_false(flags);
value= memcached_get(memc, key, strlen(key),
&length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(value == NULL);
test_true(length == 0);
test_true(flags == 0);
NULL, 0,
(time_t)0, UINT32_MAX);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_get(memc, key, strlen(key),
&length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(value == NULL);
test_true(length == 0);
test_true(flags == UINT32_MAX);
value, strlen(value),
(time_t)0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value2= memcached_get(memc, key, strlen(key),
&length, &flags, &rc);
test_true(length==strlen(value));
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(memcmp(value, value2, length)==0);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_memcmp(value, value2, length);
free(value2);
return TEST_SUCCESS;
memcached_return_t rc;
uint64_t value;
int x;
- memcached_server_st *server_pool;
memcached_st *memc;
(void)trash;
test_true(memc);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
test_true(value == 1);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
test_true(value == MEMCACHED_HASH_MD5);
- server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
memcached_server_push(memc, server_pool);
/* verify that the server list was parsed okay. */
test_true(memcached_server_count(memc) == 8);
- test_true(strcmp(server_pool[0].hostname, "10.0.1.1") == 0);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
test_true(server_pool[0].port == 11211);
test_true(server_pool[0].weight == 600);
- test_true(strcmp(server_pool[2].hostname, "10.0.1.3") == 0);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
test_true(server_pool[2].port == 11211);
test_true(server_pool[2].weight == 200);
- test_true(strcmp(server_pool[7].hostname, "10.0.1.8") == 0);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
test_true(server_pool[7].port == 11211);
test_true(server_pool[7].weight == 100);
*/
/* sighandler_t function that always asserts false */
-static void fail(int unused)
+static void fail(int)
{
- (void)unused;
assert(0);
}
test_true(memc_clone);
/* only binproto uses getq for mget */
- memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
/* empty the cache to ensure misses (hence non-responses) */
- memcached_return_t rc= memcached_flush(memc_clone, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_flush(memc_clone, 0));
size_t* key_lengths= new (std::nothrow) size_t[key_count];
test_true(key_lengths);
snprintf(buffer, 30, "%u", x);
keys[x]= strdup(buffer);
+ test_true(keys[x]);
key_lengths[x]= strlen(keys[x]);
}
oldalarm= signal(SIGALRM, fail);
alarm(5);
- test_true_got(memcached_success(memcached_mget(memc_clone, (const char **)keys, key_lengths, key_count)), memcached_last_error_message(memc_clone));
+ test_compare_got(MEMCACHED_SUCCESS,
+ memcached_mget(memc_clone, (const char **)keys, key_lengths, key_count), memcached_last_error_message(memc_clone));
alarm(0);
signal(SIGALRM, oldalarm);
- size_t keys_returned;
- test_true(fetch_all_results(memc, &keys_returned) == TEST_SUCCESS);
+ memcached_return_t rc;
+ uint32_t flags;
+ char return_key[MEMCACHED_MAX_KEY];
+ size_t return_key_length;
+ char *return_value;
+ size_t return_value_length;
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
+ &return_value_length, &flags, &rc)))
+ {
+ test_false(return_value); // There are no keys to fetch, so the value should never be returned
+ }
+ test_compare(MEMCACHED_NOTFOUND, rc);
+ test_compare(0, return_value_length);
+ test_compare(0, return_key_length);
+ test_false(return_key[0]);
+ test_false(return_value);
for (unsigned int x= 0; x < key_count; x++)
{
if (test_rc != TEST_SUCCESS)
return test_rc;
- test_return_t rc;
-
/* should work as of r580 */
- rc= _user_supplied_bug21(memc, 10);
- test_true(rc == TEST_SUCCESS);
+ test_compare(TEST_SUCCESS,
+ _user_supplied_bug21(memc, 10));
/* should fail as of r580 */
- rc= _user_supplied_bug21(memc, 1000);
- test_true(rc == TEST_SUCCESS);
+ test_compare(TEST_SUCCESS,
+ _user_supplied_bug21(memc, 1000));
return TEST_SUCCESS;
}
test_true(memc);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
test_true(value == 1);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
test_true(value == MEMCACHED_HASH_MD5);
/* server should be removed when in delay */
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS);
test_true(value == 1);
/* verify that the server list was parsed okay. */
test_true(memcached_server_count(memc) == 8);
- test_true(strcmp(server_pool[0].hostname, "10.0.1.1") == 0);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
test_true(server_pool[0].port == 11211);
test_true(server_pool[0].weight == 600);
- test_true(strcmp(server_pool[2].hostname, "10.0.1.3") == 0);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
test_true(server_pool[2].port == 11211);
test_true(server_pool[2].weight == 200);
- test_true(strcmp(server_pool[7].hostname, "10.0.1.8") == 0);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
test_true(server_pool[7].port == 11211);
test_true(server_pool[7].weight == 100);
instance=
memcached_server_instance_by_position(memc, server_idx);
const char *hostname = memcached_server_name(instance);
- test_true(strcmp(hostname, ketama_test_cases[x].server) == 0);
+ test_strcmp(hostname, ketama_test_cases[x].server);
}
memcached_server_list_free(server_pool);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
test_true(value == 1);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
test_true(value == MEMCACHED_HASH_MD5);
&return_value_length, &flags, &rc);
/*
test_true(return_value);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
*/
if (rc == MEMCACHED_SUCCESS && return_value)
free(return_value);
static test_return_t mget_read(memcached_st *memc)
{
- if (not libmemcached_util_version_check(memc, 1, 4, 4))
- return TEST_SKIPPED;
-
- memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
- test_true_got(memcached_success(rc), memcached_strerror(NULL, rc));
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_mget(memc, global_keys, global_keys_length, global_count),
+ memcached_strerror(NULL, rc));
// Go fetch the keys and test to see if all of them were returned
{
size_t keys_returned;
- test_true(fetch_all_results(memc, &keys_returned) == TEST_SUCCESS);
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, MEMCACHED_SUCCESS));
+ test_true(keys_returned > 0);
char buffer[30];
snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)keys_returned);
- test_true_got(global_count == keys_returned, buffer);
+ test_compare_got(global_count, keys_returned, buffer);
}
-
return TEST_SUCCESS;
}
static test_return_t mget_read_result(memcached_st *memc)
{
- if (not libmemcached_util_version_check(memc, 1, 4, 4))
- return TEST_SKIPPED;
-
- memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
- test_true_got(memcached_success(rc), memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
/* Turn this into a help function */
{
memcached_result_st results_obj;
memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ memcached_return_t rc;
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
{
test_true(results);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
+ test_compare(MEMCACHED_END, rc);
memcached_result_free(&results_obj);
}
return TEST_SUCCESS;
}
-static test_return_t mget_read_function(memcached_st *memc)
+static test_return_t mget_read_internal_result(memcached_st *memc)
{
- if (not libmemcached_util_version_check(memc, 1, 4, 4))
- return TEST_SKIPPED;
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+ {
+ memcached_result_st *results= NULL;
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, results, &rc)))
+ {
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ }
+ test_compare(MEMCACHED_END, rc);
+
+ memcached_result_free(results);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t mget_read_partial_result(memcached_st *memc)
+{
+
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+
+ // We will scan for just one key
+ {
+ memcached_result_st results_obj;
+ memcached_result_st *results= memcached_result_create(memc, &results_obj);
+
+ memcached_return_t rc;
+ results= memcached_fetch_result(memc, results, &rc);
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ memcached_result_free(&results_obj);
+ }
+
+ // We already have a read happening, lets start up another one.
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+ {
+ memcached_result_st results_obj;
+ memcached_result_st *results= memcached_result_create(memc, &results_obj);
+
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
+ {
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ }
+ test_compare(MEMCACHED_END, rc);
+
+ memcached_result_free(&results_obj);
+ }
+
+ return TEST_SUCCESS;
+}
- memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
+static test_return_t mget_read_function(memcached_st *memc)
+{
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
- test_true_got(memcached_success(rc), memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
memcached_execute_fn callbacks[]= { &callback_counter };
size_t counter= 0;
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
return TEST_SUCCESS;
}
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
}
else
static test_return_t pre_behavior_ketama(memcached_st *memc)
{
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA);
test_true(value == 1);
static test_return_t pre_behavior_ketama_weighted(memcached_st *memc)
{
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
test_true(value == 1);
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
test_true(value == MEMCACHED_HASH_MD5);
if (libmemcached_util_version_check(memc, 1, 4, 4))
{
rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
}
test_true(memcached_server_push(memc, servers) == MEMCACHED_SUCCESS);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
rc= memcached_set_sasl_auth_data(memc, user, pass);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
#else
(void)memc;
static test_return_t pre_replication(memcached_st *memc)
{
- test_true(TEST_SUCCESS == pre_binary(memc));
+ test_skip(TEST_SUCCESS, pre_binary(memc));
/*
* Make sure that we store the item on all servers
*/
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
memcached_server_count(memc) - 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS) == memcached_server_count(memc) - 1);
return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
static test_return_t pre_replication_noblock(memcached_st *memc)
{
- test_compare(TEST_SUCCESS, pre_replication(memc));
+ test_skip(TEST_SUCCESS, pre_replication(memc));
return pre_nonblock(memc);
}
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc);
test_true(value);
- test_true(memcmp(value, key, 4) == 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_memcmp(value, key, 4);
+ test_compare(MEMCACHED_SUCCESS, rc);
/* Test that we can turn it off */
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc);
test_false(value);
/* Now setup for main test */
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)key);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc);
test_true(value);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(memcmp(value, key, 4) == 0);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_memcmp(value, key, 4);
/* Set to Zero, and then Set to something too large */
{
memset(long_key, 0, 255);
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc);
test_false(value);
/* TODO, extend test to determine based on setting, what result should be */
strncpy(long_key, "Thisismorethentheallottednumberofcharacters", sizeof(long_key));
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
- //test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
- test_true(rc == MEMCACHED_SUCCESS);
+ //test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
/* Now test a key with spaces (which will fail from long key, since bad key is not set) */
strncpy(long_key, "This is more then the allotted number of characters", sizeof(long_key));
- rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key));
/* Test for a bad prefix, but with a short key */
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1));
strncpy(long_key, "dog cat", sizeof(long_key));
- rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key));
}
return TEST_SUCCESS;
cb_ptr= *(void **)&malloc_cb;
memcached_return_t rc;
- rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr));
test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(test_ptr == cb_ptr);
}
cb_ptr= *(void **)&realloc_cb;
memcached_return_t rc;
- rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr));
test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(test_ptr == cb_ptr);
}
cb_ptr= *(void **)&free_cb;
memcached_return_t rc;
- rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr));
test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(test_ptr == cb_ptr);
}
static test_return_t set_memory_alloc(memcached_st *memc)
{
- memcached_return_t rc;
- rc= memcached_set_memory_allocators(memc, NULL, my_free,
- my_realloc, my_calloc, NULL);
- test_true(rc == MEMCACHED_FAILURE);
+ test_compare(MEMCACHED_FAILURE,
+ memcached_set_memory_allocators(memc, NULL, my_free,
+ my_realloc, my_calloc, NULL));
- rc= memcached_set_memory_allocators(memc, my_malloc, my_free,
- my_realloc, my_calloc, NULL);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set_memory_allocators(memc, my_malloc, my_free,
+ my_realloc, my_calloc, NULL));
memcached_malloc_fn mem_malloc;
memcached_free_fn mem_free;
static test_return_t poll_timeout(memcached_st *memc)
{
- size_t timeout;
-
- timeout= 100;
+ size_t timeout= 100; // Not using, just checking that it sets
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
timeout= (size_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
- test_true(timeout == 100);
+ test_compare(100, timeout);
return TEST_SUCCESS;
}
memcached_analysis_st *report;
memc_stat= memcached_stat(memc, NULL, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(memc_stat);
report= memcached_analyze(memc, memc_stat, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(report);
free(report);
{
size_t counter= 0;
memcached_dump_fn callbacks[1];
- test_return_t main_rc;
callbacks[0]= &callback_dump_counter;
/* No support for Binary protocol yet */
- if (memc->flags.binary_protocol)
- return TEST_SUCCESS;
-
- main_rc= set_test3(memc);
+ test_skip(false, memc->flags.binary_protocol);
- test_true (main_rc == TEST_SUCCESS);
+ test_compare(TEST_SUCCESS, set_test3(memc));
- memcached_return_t rc= memcached_dump(memc, callbacks, (void *)&counter, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_dump(memc, callbacks, (void *)&counter, 1));
/* We may have more then 32 if our previous flush has not completed */
test_true(counter >= 32);
usleep(250);
// Release all of the memc we are holding
- assert(memcached_pool_push(resource->pool, resource->mmc) == MEMCACHED_SUCCESS);
+ assert(memcached_success(memcached_pool_push(resource->pool, resource->mmc)));
return arg;
}
{
mmc[x]= memcached_pool_pop(pool, false, &rc);
test_true(mmc[x] != NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
}
// All memc should be gone
test_true(memcached_pool_pop(pool, false, &rc) == NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
pthread_t tid;
test_pool_context_st item= { pool, mmc[9] };
pthread_create(&tid, NULL, connection_release, &item);
mmc[9]= memcached_pool_pop(pool, true, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
pthread_join(tid, NULL);
test_true(mmc[9]);
const char *key= "key";
size_t keylen= strlen(key);
// verify that I can do ops with all connections
- rc= memcached_set(mmc[0], key, keylen, "0", 1, 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(mmc[0], key, keylen, "0", 1, 0, 0));
for (size_t x= 0; x < POOL_SIZE; ++x)
{
uint64_t number_value;
- rc= memcached_increment(mmc[x], key, keylen, 1, &number_value);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(number_value == (x+1));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment(mmc[x], key, keylen, 1, &number_value));
+ test_compare(number_value, (x+1));
}
// Release them..
for (size_t x= 0; x < POOL_SIZE; ++x)
{
- test_true(memcached_pool_push(pool, mmc[x]) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_pool_push(pool, mmc[x]));
}
* when I push the item into the pool
*/
mmc[0]= memcached_pool_pop(pool, false, &rc);
- test_true(mmc[0] != NULL);
+ test_true(mmc[0]);
rc= memcached_pool_behavior_set(pool, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, 9999);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
mmc[1]= memcached_pool_pop(pool, false, &rc);
- test_true(mmc[1] != NULL);
+ test_true(mmc[1]);
- test_true(memcached_behavior_get(mmc[1], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK) == 9999);
- test_true(memcached_pool_push(pool, mmc[1]) == MEMCACHED_SUCCESS);
- test_true(memcached_pool_push(pool, mmc[0]) == MEMCACHED_SUCCESS);
+ test_compare(9999, memcached_behavior_get(mmc[1], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK));
+ test_compare(MEMCACHED_SUCCESS, memcached_pool_push(pool, mmc[1]));
+ test_compare(MEMCACHED_SUCCESS, memcached_pool_push(pool, mmc[0]));
mmc[0]= memcached_pool_pop(pool, false, &rc);
- test_true(memcached_behavior_get(mmc[0], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK) == 9999);
- test_true(memcached_pool_push(pool, mmc[0]) == MEMCACHED_SUCCESS);
+ test_compare(9999, memcached_behavior_get(mmc[0], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK));
+ test_compare(MEMCACHED_SUCCESS, memcached_pool_push(pool, mmc[0]));
test_true(memcached_pool_destroy(pool) == memc);
static test_return_t util_version_test(memcached_st *memc)
{
- bool if_successful;
-
- if_successful= libmemcached_util_version_check(memc, 0, 0, 0);
- test_true(if_successful == true);
+ bool if_successful= libmemcached_util_version_check(memc, 0, 0, 0);
+ test_true(if_successful);
if_successful= libmemcached_util_version_check(memc, 9, 9, 9);
test_true(libmemcached_util_ping(memcached_server_name(instance),
memcached_server_port(instance), &rc));
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
return TEST_SUCCESS;
}
{
(void)memc;
memcached_st *tl_memc_h;
- memcached_server_st *servers;
const char *key= "MemcachedLives";
size_t len;
// Create a handle.
tl_memc_h= memcached_create(NULL);
- servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
+ memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
+ test_true(servers);
memcached_server_push(tl_memc_h, servers);
memcached_server_list_free(servers);
value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc);
test_false(value);
- test_true(len == 0);
- test_false(rc == MEMCACHED_SUCCESS);
+ test_compare(0, len);
+ test_true(memcached_failed(rc));
memcached_free(tl_memc_h);
value= memcached_get(memc, key, strlen(key), &len, &flags, &rc);
test_false(value);
- test_true(len == 0);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(0, len);
+ test_compare(MEMCACHED_NOTFOUND, rc);
return TEST_SUCCESS;
}
value= memcached_get_by_key(tl_memc_h, key, strlen(key), key, strlen(key), &len, &flags, &rc);
test_false(value);
- test_true(len == 0);
- test_false(rc == MEMCACHED_SUCCESS);
+ test_compare(0, len);
+ test_true(memcached_failed(rc));
memcached_free(tl_memc_h);
value= memcached_get_by_key(memc, key, strlen(key), key, strlen(key), &len, &flags, &rc);
test_false(value);
- test_true(len == 0);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(0, len);
+ test_compare(MEMCACHED_NOTFOUND, rc);
return TEST_SUCCESS;
}
-static test_return_t ketama_compatibility_libmemcached(memcached_st *trash)
+static test_return_t ketama_compatibility_libmemcached(memcached_st *)
{
- memcached_return_t rc;
- uint64_t value;
- int x;
- memcached_server_st *server_pool;
- memcached_st *memc;
-
- (void)trash;
-
- memc= memcached_create(NULL);
+ memcached_st *memc= memcached_create(NULL);
test_true(memc);
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- test_true(value == 1);
+ uint64_t value;
+ test_compare(1, value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
- test_true(memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) == MEMCACHED_SUCCESS);
- test_true(memcached_behavior_get_distribution(memc) == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA));
+ test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, memcached_behavior_get_distribution(memc));
- server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
memcached_server_push(memc, server_pool);
/* verify that the server list was parsed okay. */
- test_true(memcached_server_count(memc) == 8);
+ test_compare(8, memcached_server_count(memc));
test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_true(server_pool[0].port == 11211);
- test_true(server_pool[0].weight == 600);
+ test_compare(11211, server_pool[0].port);
+ test_compare(600, server_pool[0].weight);
test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_true(server_pool[2].port == 11211);
- test_true(server_pool[2].weight == 200);
+ test_compare(11211, server_pool[2].port);
+ test_compare(200, server_pool[2].weight);
test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_true(server_pool[7].port == 11211);
- test_true(server_pool[7].weight == 100);
+ test_compare(11211, server_pool[7].port);
+ test_compare(100, server_pool[7].weight);
/* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
* us test the boundary wraparound.
test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
/* verify the standard ketama set. */
- for (x= 0; x < 99; x++)
+ for (uint32_t x= 0; x < 99; x++)
{
uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
memcached_server_instance_st instance=
return TEST_SUCCESS;
}
-static test_return_t ketama_compatibility_spymemcached(memcached_st *trash)
+static test_return_t ketama_compatibility_spymemcached(memcached_st *)
{
- memcached_return_t rc;
uint64_t value;
- memcached_server_st *server_pool;
- memcached_st *memc;
-
- (void)trash;
- memc= memcached_create(NULL);
+ memcached_st *memc= memcached_create(NULL);
test_true(memc);
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- test_true(value == 1);
+ test_compare(1, value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
- test_true(memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY) == MEMCACHED_SUCCESS);
- test_true(memcached_behavior_get_distribution(memc) == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY));
+ test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, memcached_behavior_get_distribution(memc));
- server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
- assert(server_pool);
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ test_true(server_pool);
memcached_server_push(memc, server_pool);
/* verify that the server list was parsed okay. */
- test_true(memcached_server_count(memc) == 8);
+ test_compare(8, memcached_server_count(memc));
test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_true(server_pool[0].port == 11211);
- test_true(server_pool[0].weight == 600);
+ test_compare(11211, server_pool[0].port);
+ test_compare(600, server_pool[0].weight);
test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_true(server_pool[2].port == 11211);
- test_true(server_pool[2].weight == 200);
+ test_compare(11211, server_pool[2].port);
+ test_compare(200, server_pool[2].weight);
test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_true(server_pool[7].port == 11211);
- test_true(server_pool[7].weight == 100);
+ test_compare(11211, server_pool[7].port);
+ test_compare(100, server_pool[7].weight);
/* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
* us test the boundary wraparound.
size_t keylen= strlen(key);
memcached_return_t ret= memcached_append(memc, key, keylen, key, keylen, 0, 0);
- test_true(ret == MEMCACHED_NOTSTORED);
+ test_compare(MEMCACHED_NOTSTORED, ret);
size_t size= 2048 * 1024;
char *data= (char*)calloc(1, size);
test_true(data);
- ret= memcached_set(memc, key, keylen, data, size, 0, 0);
- test_true(ret == MEMCACHED_E2BIG);
+ test_compare(MEMCACHED_E2BIG,
+ memcached_set(memc, key, keylen, data, size, 0, 0));
free(data);
return TEST_SUCCESS;
key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
keys[x]= strdup(k);
- test_true(keys[x] != NULL);
+ test_true(keys[x]);
}
/*
*/
for (size_t y= 0; y < 2; y++)
{
- rc= memcached_mget(memc, (const char**)keys, key_length, max_keys);
- test_true(rc == MEMCACHED_SUCCESS);
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, (const char**)keys, key_length, max_keys));
+
+ test_compare(y ? MEMCACHED_SUCCESS : MEMCACHED_NOTFOUND,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
if (y == 0)
{
/* The first iteration should give me a 100% cache miss. verify that*/
char blob[1024]= { 0 };
- test_true(counter == 0);
+ test_false(counter);
for (size_t x= 0; x < max_keys; ++x)
{
else
{
/* Verify that we received all of the key/value pairs */
- test_true(counter == max_keys);
+ test_compare(counter, max_keys);
}
}
{
memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
return regression_bug_434843(memc);
}
{
memcached_return_t rc;
memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
- char *bytes= memcached_stat_get_value(memc, memc_stat, "bytes", &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(bytes != NULL);
- char *bytes_read= memcached_stat_get_value(memc, memc_stat,
- "bytes_read", &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(bytes_read != NULL);
+ char *bytes_str= memcached_stat_get_value(memc, memc_stat, "bytes", &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(bytes_str);
+ char *bytes_read_str= memcached_stat_get_value(memc, memc_stat,
+ "bytes_read", &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(bytes_read_str);
- char *bytes_written= memcached_stat_get_value(memc, memc_stat,
- "bytes_written", &rc);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(bytes_written != NULL);
+ char *bytes_written_str= memcached_stat_get_value(memc, memc_stat,
+ "bytes_written", &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(bytes_written_str);
- test_true(strcmp(bytes, bytes_read) != 0);
- test_true(strcmp(bytes, bytes_written) != 0);
+ unsigned long long bytes= strtoull(bytes_str, 0, 10);
+ unsigned long long bytes_read= strtoull(bytes_read_str, 0, 10);
+ unsigned long long bytes_written= strtoull(bytes_written_str, 0, 10);
+
+ test_true(bytes != bytes_read);
+ test_true(bytes != bytes_written);
/* Release allocated resources */
- free(bytes);
- free(bytes_read);
- free(bytes_written);
+ free(bytes_str);
+ free(bytes_read_str);
+ free(bytes_written_str);
memcached_stat_free(NULL, memc_stat);
return TEST_SUCCESS;
*/
static test_return_t regression_bug_442914(memcached_st *memc)
{
- memcached_return_t rc;
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
uint32_t number_of_hosts= memcached_server_count(memc);
for (uint32_t x= 0; x < 250; ++x)
{
len= (size_t)snprintf(k, sizeof(k), "%0250u", x);
- rc= memcached_delete(memc, k, len, 0);
+ memcached_return_t rc= memcached_delete(memc, k, len, 0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
(void)snprintf(k, sizeof(k), "%037u", 251U);
len= strlen(k);
- rc= memcached_delete(memc, k, len, 0);
+ memcached_return_t rc= memcached_delete(memc, k, len, 0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0);
- test_true(rc == MEMCACHED_SUCCESS);
- rc= memcached_delete(memc, k, len, 0);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0));
+ test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, k, len, 0));
memc->number_of_hosts= number_of_hosts;
memcached_server_instance_st instance_one;
memcached_server_instance_st instance_two;
- if (memcached_server_count(memc) < 3 || pre_replication(memc) != TEST_SUCCESS)
+ if (memcached_server_count(memc) < 3 or pre_replication(memc) != TEST_SUCCESS)
return TEST_SKIPPED;
- memcached_return_t rc;
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2));
const size_t max_keys= 100;
char **keys= (char**)calloc(max_keys, sizeof(char*));
key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
keys[x]= strdup(k);
- test_true(keys[x] != NULL);
- rc= memcached_set(memc, k, key_length[x], k, key_length[x], 0, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_true(keys[x]);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, k, key_length[x], k, key_length[x], 0, 0));
}
/*
/* Verify that all messages are stored, and we didn't stuff too much
* into the servers
*/
- rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
size_t counter= 0;
memcached_execute_fn callbacks[]= { &callback_counter };
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1),
+ memcached_strerror(NULL, rc));
+
/* Verify that we received all of the key/value pairs */
- test_true(counter == max_keys);
+ test_compare(counter, max_keys);
memcached_quit(memc);
/*
((memcached_server_write_instance_st)instance_one)->port= 0;
((memcached_server_write_instance_st)instance_two)->port= 0;
- rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
counter= 0;
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
- test_true(counter == (unsigned int)max_keys);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
+ test_compare(counter, (unsigned int)max_keys);
/* restore the memc handle */
((memcached_server_write_instance_st)instance_one)->port= port0;
{
if (x & 1)
{
- rc= memcached_delete(memc, keys[x], key_length[x], 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_delete(memc, keys[x], key_length[x], 0));
}
}
((memcached_server_write_instance_st)instance_two)->port= 0;
/* now retry the command, this time we should have cache misses */
- rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
counter= 0;
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
- test_true(counter == (unsigned int)(max_keys >> 1));
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1),
+ memcached_strerror(NULL, rc));
+ test_compare(counter, (unsigned int)(max_keys >> 1));
/* Release allocated resources */
for (size_t x= 0; x < max_keys; ++x)
static test_return_t regression_bug_463297(memcached_st *memc)
{
memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone != NULL);
+ test_true(memc_clone);
test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS);
memcached_server_instance_st instance=
{
/* Binary protocol doesn't support deferred delete */
memcached_st *bin_clone= memcached_clone(NULL, memc);
- test_true(bin_clone != NULL);
- test_true(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS);
- test_true(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS);
+ test_true(bin_clone);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
+ test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(bin_clone, "foo", 3, 1));
memcached_free(bin_clone);
memcached_quit(memc_clone);
/* If we know the server version, deferred delete should fail
* with invalid arguments */
- test_true(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS);
+ test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(memc_clone, "foo", 3, 1));
/* If we don't know the server version, we should get a protocol error */
memcached_return_t rc= memcached_delete(memc, "foo", 3, 1);
test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc));
/* Same goes for noreply... */
- test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
rc= memcached_delete(memc, "foo", 3, 1);
test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc));
/* but a normal request should go through (and be buffered) */
- test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED);
- test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_BUFFERED, (rc= memcached_delete(memc, "foo", 3, 0)));
+ test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
- test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0));
/* unbuffered noreply should be success */
- test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, "foo", 3, 0));
/* unbuffered with reply should be not found... */
- test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS);
- test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0));
+ test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, "foo", 3, 0));
}
memcached_free(memc_clone);
test_true(servers);
mine= memcached_create(NULL);
rc= memcached_server_push(mine, servers);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
memcached_server_list_free(servers);
test_true(mine);
disconnected_server= memcached_server_get_last_disconnect(mine);
test_true_got(disconnected_server, memcached_strerror(mine, rc));
test_compare(9, memcached_server_port(disconnected_server));
- test_true(strncmp(memcached_server_name(disconnected_server),"localhost",9) == 0);
+ test_false(strncmp(memcached_server_name(disconnected_server),"localhost",9));
memcached_quit(mine);
memcached_free(mine);
{
const char *msg= memcached_strerror(memc, memcached_return_t(x));
memcached_return_t ret= memcached_set(memc, msg, strlen(msg), NULL, 0, (time_t)0, (uint32_t)0);
- test_compare_got(MEMCACHED_WRITE_FAILURE, ret, memcached_strerror(NULL, ret));
+ test_compare_got(MEMCACHED_CONNECTION_FAILURE, ret, memcached_last_error_message(memc));
memcached_server_instance_st disconnected_server= memcached_server_get_last_disconnect(memc);
test_true(disconnected_server);
static test_return_t test_server_failure(memcached_st *memc)
{
- memcached_st *local_memc;
memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0);
- local_memc= memcached_create(NULL);
+ memcached_st *local_memc= memcached_create(NULL);
memcached_server_add(local_memc, memcached_server_name(instance), memcached_server_port(instance));
memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 2);
uint32_t server_count= memcached_server_count(local_memc);
-
- test_true(server_count == 1);
+ test_compare(1, server_count);
// Disable the server
instance= memcached_server_instance_by_position(local_memc, 0);
((memcached_server_write_instance_st)instance)->server_failure_counter= 2;
memcached_return_t rc;
- rc= memcached_set(local_memc, "foo", strlen("foo"),
- NULL, 0,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SERVER_MARKED_DEAD);
+ test_compare_got(MEMCACHED_SERVER_MARKED_DEAD,
+ rc= memcached_set(local_memc, "foo", strlen("foo"), NULL, 0, (time_t)0, (uint32_t)0),
+ memcached_last_error_message(local_memc));
((memcached_server_write_instance_st)instance)->server_failure_counter= 0;
- rc= memcached_set(local_memc, "foo", strlen("foo"),
- NULL, 0,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_set(local_memc, "foo", strlen("foo"), NULL, 0, (time_t)0, (uint32_t)0),
+ memcached_strerror(NULL, rc));
+#if 0
+ memcached_last_error_message(local_memc));
+#endif
memcached_free(local_memc);
memc->state.is_time_for_rebuild= true;
uint32_t new_count= memcached_server_count(memc);
- test_true(count == new_count);
+ test_compare(count, new_count);
#if 0
test_true(count == new_count + 1 );
static test_return_t memcached_stat_execute_test(memcached_st *memc)
{
memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_stat_execute(memc, "slabs", stat_printer, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_stat_execute(memc, "items", stat_printer, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_stat_execute(memc, "sizes", stat_printer, NULL);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
return TEST_SUCCESS;
}
* Please note that this isn't bullet proof, because an error could
* occur...
*/
- test_true(instance->server_failure_counter == 0);
+ test_compare(0, instance->server_failure_counter);
/* restore the instance */
memc->number_of_hosts= number_of_hosts;
/* put failure limit to 1 */
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1);
- assert(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1));
/* Put a retry timeout to effectively activate failure_limit effect */
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1);
- assert(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1));
/* change behavior that triggers memcached_quit()*/
- rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
- assert(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1));
/* Check if we still are connected */
string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_true_got(rc == MEMCACHED_SUCCESS, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
test_true(string);
free(string);
memcached_free(memc_clone);
size_t *key_length= (size_t *)calloc(max_keys, sizeof(size_t));
/* First add all of the items.. */
- bool slept= false;
char blob[1024]= { 0 };
- memcached_return rc;
for (size_t x= 0; x < max_keys; ++x)
{
char k[251];
key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
keys[x]= strdup(k);
- assert(keys[x] != NULL);
- rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
-#ifdef __APPLE__
- if (rc == MEMCACHED_SERVER_MARKED_DEAD)
- {
- break; // We are out of business
- }
-#endif
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED || rc == MEMCACHED_TIMEOUT); // MEMCACHED_TIMEOUT <-- only observed on OSX
-
- if (rc == MEMCACHED_TIMEOUT && slept == false)
- {
- x++;
- sleep(1);// We will try to sleep
- slept= true;
- }
- else if (rc == MEMCACHED_TIMEOUT && slept == true)
- {
- // We failed to send everything.
- break;
- }
+ test_true(keys[x]);
+ memcached_return rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); // MEMCACHED_TIMEOUT <-- hash been observed on OSX
}
- if (rc != MEMCACHED_SERVER_MARKED_DEAD)
{
/* Try to get all of them with a large multiget */
size_t counter= 0;
memcached_execute_function callbacks[]= { &callback_counter };
- rc= memcached_mget_execute(memc, (const char**)keys, key_length,
- (size_t)max_keys, callbacks, &counter, 1);
+ memcached_return_t rc= memcached_mget_execute(memc, (const char**)keys, key_length,
+ (size_t)max_keys, callbacks, &counter, 1);
+ test_compare(MEMCACHED_SUCCESS, rc);
- assert(rc == MEMCACHED_SUCCESS);
char* the_value= NULL;
char the_key[MEMCACHED_MAX_KEY];
size_t the_key_length;
} while ( (the_value!= NULL) && (rc == MEMCACHED_SUCCESS));
- assert(rc == MEMCACHED_END);
+ test_compare(MEMCACHED_END, rc);
/* Verify that we got all of the items */
- assert(counter == max_keys);
+ test_compare(counter, max_keys);
}
/* Release all allocated resources */
{
memcached_st *memc= memcached_create(NULL);
test_true(memc);
- test_true(memcached_success(memcached_server_add(memc, "10.2.3.4", 11211)));
+ test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "10.2.3.4", 11211));
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 1000);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1000);
test_false(value);
test_compare(0, length);
- test_true_got(rc == MEMCACHED_TIMEOUT || rc == MEMCACHED_ERRNO || rc == MEMCACHED_FAILURE, memcached_strerror(memc, rc));
+ test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(memc, rc));
memcached_free(memc);
return TEST_SUCCESS;
}
+#define regression_bug_655423_COUNT 6000
+static test_return_t regression_bug_655423(memcached_st *memc)
+{
+ memcached_st *clone= memcached_clone(NULL, memc);
+ memc= NULL; // Just to make sure it is not used
+ test_true(clone);
+ char payload[100];
+
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1));
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1));
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 1));
+
+ memset(payload, int('x'), sizeof(payload));
+
+ for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+ {
+ char key[1024];
+ snprintf(key, sizeof(key), "%u", x);
+
+ test_compare(MEMCACHED_SUCCESS, memcached_set(clone, key, strlen(key), payload, sizeof(payload), 0, 0));
+ }
+
+ for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+ {
+ char key[1024];
+ snprintf(key, sizeof(key), "%u", x);
+
+ size_t value_length;
+ memcached_return_t rc;
+ char *value= memcached_get(clone, key, strlen(key), &value_length, NULL, &rc);
+
+ if (rc == MEMCACHED_NOTFOUND)
+ {
+ test_false(value);
+ test_compare(0, value_length);
+ continue;
+ }
+
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_true(value);
+ test_compare(100, value_length);
+ free(value);
+ }
+
+ char **keys= (char**)calloc(regression_bug_655423_COUNT, sizeof(char*));
+ size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t));
+ for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+ {
+ char key[1024];
+ snprintf(key, sizeof(key), "%u", x);
+
+ keys[x]= strdup(key);
+ key_length[x]= strlen(key);
+ }
+
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_mget(clone, (const char* const *)keys, key_length, regression_bug_655423_COUNT),
+ memcached_strerror(NULL, rc));
+
+ uint32_t count= 0;
+ memcached_result_st *result= NULL;
+ while ((result= memcached_fetch_result(clone, result, NULL)))
+ {
+ test_compare(100, memcached_result_length(result));
+ count++;
+ }
+
+ test_true(count > 100); // If we don't get back atleast this, something is up
+
+ /* Release all allocated resources */
+ for (size_t x= 0; x < regression_bug_655423_COUNT; ++x)
+ {
+ free(keys[x]);
+ }
+ free(keys);
+ free(key_length);
+
+
+ memcached_free(clone);
+
+ return TEST_SUCCESS;
+}
+
+/*
+ * Test that ensures that buffered set to not trigger problems during io_flush
+ */
+#define regression_bug_490520_COUNT 200480
+static test_return_t regression_bug_490520(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,1);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1000);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,1);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 3600);
+
+ memc->number_of_hosts= 1;
+
+ char **keys= (char **)calloc(regression_bug_490520_COUNT, sizeof(char*));
+ size_t *key_length= (size_t *)calloc(regression_bug_490520_COUNT, sizeof(size_t));
+
+ /* First add all of the items.. */
+ char blob[3333] = {0};
+ for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x)
+ {
+ char k[251];
+ key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x);
+ keys[x]= strdup(k);
+ test_true(keys[x]);
+
+ memcached_return rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
+ }
+
+ for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x)
+ {
+ free(keys[x]);
+ }
+ free(keys);
+ free(key_length);
+
+ return TEST_SUCCESS;
+}
+
static void memcached_die(memcached_st* mc, memcached_return error, const char* what, uint32_t it)
{
fprintf(stderr, "Iteration #%u: ", it);
static test_return_t sasl_auth_test(memcached_st *memc)
{
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
- memcached_return_t rc;
-
- rc= memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_SUCCESS);
- test_true((rc= memcached_destroy_sasl_auth_data(memc)) == MEMCACHED_SUCCESS);
- test_true((rc= memcached_destroy_sasl_auth_data(memc)) == MEMCACHED_FAILURE);
- test_true((rc= memcached_destroy_sasl_auth_data(NULL)) == MEMCACHED_FAILURE);
+ test_compare(MEMCACHED_SUCCESS, memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0));
+ test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, "foo", 3, 0));
+ test_compare(MEMCACHED_SUCCESS, memcached_destroy_sasl_auth_data(memc));
+ test_compare(MEMCACHED_FAILURE, memcached_destroy_sasl_auth_data(memc));
+ test_compare(MEMCACHED_FAILURE, memcached_destroy_sasl_auth_data(NULL));
memcached_quit(memc);
- rc= memcached_set_sasl_auth_data(memc,
- getenv("LIBMEMCACHED_TEST_SASL_USERNAME"),
- getenv("LIBMEMCACHED_TEST_SASL_SERVER"));
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set_sasl_auth_data(memc,
+ getenv("LIBMEMCACHED_TEST_SASL_USERNAME"),
+ getenv("LIBMEMCACHED_TEST_SASL_SERVER")));
- rc= memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_AUTH_FAILURE);
- test_true(memcached_destroy_sasl_auth_data(memc) == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_AUTH_FAILURE,
+ memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0));
+ test_compare(MEMCACHED_SUCCESS, memcached_destroy_sasl_auth_data(memc));
memcached_quit(memc);
return TEST_SUCCESS;
{"set3", 0, (test_callback_fn)set_test3 },
{"dump", 1, (test_callback_fn)dump_test},
{"add", 1, (test_callback_fn)add_test },
+ {"memcached_fetch_result(MEMCACHED_NOTFOUND)", 1, (test_callback_fn)memcached_fetch_result_NOT_FOUND },
{"replace", 1, (test_callback_fn)replace_test },
{"delete", 1, (test_callback_fn)delete_test },
{"get", 1, (test_callback_fn)get_test },
{0, 0, (test_callback_fn)0}
};
+test_st haldenbrand_tests[] ={
+ {"memcached_set", 0, (test_callback_fn)user_supplied_bug1 },
+ {"memcached_get()", 0, (test_callback_fn)user_supplied_bug2 },
+ {"memcached_mget()", 0, (test_callback_fn)user_supplied_bug3 },
+ {0, 0, (test_callback_fn)0}
+};
+
test_st user_tests[] ={
- {"user_supplied_bug1", 0, (test_callback_fn)user_supplied_bug1 },
- {"user_supplied_bug2", 0, (test_callback_fn)user_supplied_bug2 },
- {"user_supplied_bug3", 0, (test_callback_fn)user_supplied_bug3 },
- {"user_supplied_bug4", 0, (test_callback_fn)user_supplied_bug4 },
+ {"user_supplied_bug4", true, (test_callback_fn)user_supplied_bug4 },
{"user_supplied_bug5", 1, (test_callback_fn)user_supplied_bug5 },
{"user_supplied_bug6", 1, (test_callback_fn)user_supplied_bug6 },
{"user_supplied_bug7", 1, (test_callback_fn)user_supplied_bug7 },
{"lp:?", 1, (test_callback_fn)regression_bug_ },
{"lp:728286", 1, (test_callback_fn)regression_bug_728286 },
{"lp:581030", 1, (test_callback_fn)regression_bug_581030 },
+ {"lp:71231153 connect()", 1, (test_callback_fn)regression_bug_71231153_connect },
+ {"lp:71231153 poll()", 1, (test_callback_fn)regression_bug_71231153_poll },
+ {"lp:655423", 1, (test_callback_fn)regression_bug_655423 },
+ {"lp:490520", 1, (test_callback_fn)regression_bug_490520 },
{0, 0, (test_callback_fn)0}
};
{"generate_data", 1, (test_callback_fn)generate_data },
{"mget_read", 0, (test_callback_fn)mget_read },
{"mget_read_result", 0, (test_callback_fn)mget_read_result },
+ {"memcached_fetch_result() use internal result", 0, (test_callback_fn)mget_read_internal_result },
+ {"memcached_fetch_result() partial read", 0, (test_callback_fn)mget_read_partial_result },
{"mget_read_function", 0, (test_callback_fn)mget_read_function },
{"cleanup", 1, (test_callback_fn)cleanup_pairs },
{"generate_large_pairs", 1, (test_callback_fn)generate_large_pairs },
{"result", 0, 0, result_tests},
{"async", (test_callback_fn)pre_nonblock, 0, async_tests},
{"async_binary", (test_callback_fn)pre_nonblock_binary, 0, async_tests},
+ {"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests},
{"user", 0, 0, user_tests},
{"generate", 0, 0, generate_tests},
{"generate_hsieh", (test_callback_fn)pre_hsieh, 0, generate_tests},
#define BUILDING_LIBMEMCACHED
// !NEVER use common.h, always use memcached.h in your own apps
#include <libmemcached/common.h>
+#include <libmemcached/util.h>
#include "tests/parser.h"
#include "tests/print.h"
return TEST_SUCCESS;
}
+
+/*
+ By setting the timeout value to zero, we force poll() to return immediatly.
+*/
+test_return_t regression_bug_71231153_connect(memcached_st *)
+{
+ if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip
+ return TEST_SKIPPED;
+
+ { // Test the connect-timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
+ memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0"));
+ test_true(memc);
+ test_compare(0, memc->connect_timeout);
+ test_compare(MEMCACHED_DEFAULT_TIMEOUT, memc->poll_timeout);
+
+ memcached_return_t rc;
+ size_t value_len;
+ char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc);
+ test_false(value);
+ test_compare(0, value_len);
+ test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc));
+
+ memcached_free(memc);
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t regression_bug_71231153_poll(memcached_st *)
+{
+ if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip
+ return TEST_SKIPPED;
+
+ { // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
+ memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0"));
+ test_true(memc);
+ test_compare(MEMCACHED_DEFAULT_CONNECT_TIMEOUT, memc->connect_timeout);
+ test_compare(0, memc->poll_timeout);
+
+ memcached_return_t rc;
+ size_t value_len;
+ char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc);
+ test_false(value);
+ test_compare(0, value_len);
+ test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc));
+
+ memcached_free(memc);
+ }
+
+ return TEST_SUCCESS;
+}
LIBTEST_INTERNAL_API
test_return_t test_hostname_port_weight(memcached_st *);
+LIBTEST_INTERNAL_API
+test_return_t regression_bug_71231153_connect(memcached_st *);
+
+LIBTEST_INTERNAL_API
+test_return_t regression_bug_71231153_poll(memcached_st *);
+
#ifdef __cplusplus
}
#endif
vector<char> return_value;
/* We need to empty the server before we continue the test */
- test_true(memc.flush(0));
+ test_true(memc.flush());
test_true(memc.mget(keys));
- while ((mc_rc= memc.fetch(return_key, return_value)) != MEMCACHED_END)
- {
- test_true(return_value.size());
- return_value.clear();
- }
- test_compare(mc_rc, MEMCACHED_END);
+ test_compare(MEMCACHED_NOTFOUND,
+ memc.fetch(return_key, return_value));
test_true(memc.setAll(keys, values, 50, 9));
test_true(memc.mget(keys));
-
- while ((mc_rc= memc.fetch(return_key, return_value)) != MEMCACHED_END)
+ size_t count= 0;
+ while ((mc_rc= memc.fetch(return_key, return_value)) == MEMCACHED_SUCCESS)
{
test_compare(return_key.length(), return_value.size());
test_memcmp(&return_value[0], return_key.c_str(), return_value.size());
+ count++;
}
+ test_compare(values.size(), count);
return TEST_SUCCESS;
}