<NME> infinite_set_get.py
<BEF> import time
from libmc import Client
# from cmemcached import Client


def main():
    mc = Client(['127.0.0.1:%d' % (21211 + i) for i in range(10)])
    dct = {'test_key_%d' % i: 'i' * 1000 for i in range(10)}
    while True:
        print '%.2f: set_multi: %r' % (time.time(), mc.set_multi(dct))
        print '%.2f: get_multi: %r' % (
            time.time(), mc.get_multi(dct.keys()) == dct
        )
        time.sleep(0.5)
        print


if __name__ == '__main__':
    main()

<MSG> Merge pull request #21 from mckelvin/travis

Travis-CI: Migrating from legacy to container-based infrastructure
<DFF> @@ -1,6 +1,5 @@
 import time
 from libmc import Client
-# from cmemcached import Client
 
 
 def main():

{'commit': 'diff --git a/.travis.yml b/.travis.yml\nindex 2bdfd62..a189483 100644\n--- a/.travis.yml\n+++ b/.travis.yml\n@@ -1,42 +1,37 @@\n language: python\n \n-os:\n-  - linux\n-  - osx\n+cache:\n+  directories:\n+    - $HOME/.cache/pip\n \n python:\n   - 2.7\n \n env:\n+  matrix:\n   - TEST_SUITE=unittest CMAKE_BUILD_TYPE=Release PRJ_COMPILER=clang\n   - TEST_SUITE=unittest CMAKE_BUILD_TYPE=Debug PRJ_COMPILER=clang\n   - TEST_SUITE=unittest CMAKE_BUILD_TYPE=Release PRJ_COMPILER=gcc\n   - TEST_SUITE=unittest CMAKE_BUILD_TYPE=Debug PRJ_COMPILER=gcc\n   - TEST_SUITE=benchmark\n \n+addons:\n+  apt:\n+    packages:\n+      - valgrind\n+      - cppcheck\n+      - memcached\n+      - libmemcached6\n+\n+before_install:\n+  - pip install --upgrade pip\n+\n install:\n-  - if [ $TRAVIS_OS_NAME = "linux" ]; then sudo apt-get update -yqq; fi\n-  - if [ $TRAVIS_OS_NAME = "linux" ]; then sudo apt-get install -yqq valgrind cppcheck; fi\n-  - if [ $TRAVIS_OS_NAME = "osx" ]; then brew update; fi\n-  - if [ $TRAVIS_OS_NAME = "osx" ]; then brew install valgrind cppcheck cmake; fi\n-  # install patched libmemcached from douban\n-  - wget https://github.com/xtao/douban-patched/raw/master/libmemcached-douban-1.0.18.tar.gz\n-  - tar zxf libmemcached-douban-1.0.18.tar.gz\n-  - cd libmemcached-1.0.18\n-  - ./configure --prefix=/usr && make && sudo make install\n-  - cd ..\n-  - rm -rf python-libmemcached\n-  - rm -rf libmemcached*\n-  - if [ $TRAVIS_OS_NAME = "linux" ]; then sudo ldconfig; fi\n   # install python deps\n-  - pip install -q Cython\n-  - pip install -q git+https://github.com/douban/python-libmemcached.git@master#egg=cmemcached;\n-  - if [ $TEST_SUITE = "unittest" ]; then pip install -q pytest greenify gevent numpy; fi\n-  - if [ $TEST_SUITE = "benchmark" ]; then pip install -q git+https://github.com/lericson/pylibmc@master#egg=pylibmc; fi\n-  - if [ $TEST_SUITE = "benchmark" ]; then pip install -q git+https://github.com/linsomniac/python-memcached.git@master#egg=memcache; fi\n-\n-services:\n-  - memcached\n+  - pip install Cython\n+  - if [ $TEST_SUITE = "unittest" ]; then pip install pytest greenify gevent numpy; fi\n+  - if [ $TEST_SUITE = "benchmark" ]; then pip install git+https://github.com/lericson/pylibmc@master#egg=pylibmc; fi\n+  - if [ $TEST_SUITE = "benchmark" ]; then pip install git+https://github.com/linsomniac/python-memcached.git@master#egg=memcache; fi\n \n before_script:\n   - ./misc/memcached_server start\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 4f1237c..c2fdda2 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -5,7 +5,7 @@ set(CMAKE_MACOSX_RPATH 1)\n add_definitions(-DMC_USE_SMALL_VECTOR)\n \n if (NOT CMAKE_BUILD_TYPE)\n-   set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)\n+   set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release." FORCE)\n endif (NOT CMAKE_BUILD_TYPE)\n \n set(CMAKE_CXX_FLAGS_COMMON "-Wall -fno-rtti -fno-exceptions")\ndiff --git a/libmc/__init__.py b/libmc/__init__.py\nindex 154766e..64e3e7d 100644\n--- a/libmc/__init__.py\n+++ b/libmc/__init__.py\n@@ -28,7 +28,7 @@ __VERSION__ = "0.5.4"\n __version__ = "v0.5.4"\n __author__ = "mckelvin"\n __email__ = "mckelvin@users.noreply.github.com"\n-__date__ = "Thu Jul 16 18:20:00 2015 +0800"\n+__date__ = "Thu Jul 16 18:21:13 2015 +0800"\n \n \n class Client(PyClient):\ndiff --git a/misc/init_data.py b/misc/init_data.py\ndeleted file mode 100755\nindex e98a9fb..0000000\n--- a/misc/init_data.py\n+++ /dev/null\n@@ -1,13 +0,0 @@\n-#!/usr/bin/env python\n-\n-import cmemcached\n-\n-for port in range(21211, 21231):\n-    mc = cmemcached.Client(["127.0.0.1:%d" % port])\n-    for s in (\'foo\', \'buzai\', \'tuiche\'):\n-        val = \'%s %s\' % (port, s)\n-        mc.set(s, val)\n-        assert mc.get(s) == val\n-\n-    dct = {}.fromkeys([\'foo%d\' % i for i in range(1000)], \'lizhizhuangbi\')\n-    mc.set_multi(dct)\ndiff --git a/misc/runbench.py b/misc/runbench.py\nindex 563df7a..819e71d 100644\n--- a/misc/runbench.py\n+++ b/misc/runbench.py\n@@ -20,7 +20,6 @@ BENCH_TIME = 1.0\n N_SERVERS = 20\n \n \n-import cmemcached\n import pylibmc\n import libmc\n \n@@ -131,7 +130,7 @@ def bench_get(mc, key, data):\n \n @benchmark_method\n def bench_set(mc, key, data):\n-    if isinstance(mc.mc, (libmc.Client, cmemcached.Client)):\n+    if isinstance(mc.mc, libmc.Client):\n         if not mc.set(key, data):\n             logger.warn(\'%r.set(%r, ...) fail\', mc, key)\n     else:\n@@ -148,7 +147,7 @@ def bench_get_multi(mc, keys, pairs):\n @benchmark_method\n def bench_set_multi(mc, keys, pairs):\n     ret = mc.set_multi(pairs)\n-    if isinstance(mc.mc, (libmc.Client, cmemcached.Client)):\n+    if isinstance(mc.mc, libmc.Client):\n         if not ret:\n             logger.warn(\'%r.set_multi fail\', mc)\n     else:\n@@ -260,14 +259,6 @@ participants = [\n         ), \'libmc1\')\n     ),\n \n-    Participant(\n-        name=\'python-libmemcached(md5 / ketama / nodelay / nonblocking\'\n-             \', from douban)\',\n-        factory=lambda: Prefix(__import__(\'cmemcached\').Client(\n-            servers, comp_threshold=4000\n-        ), \'cmemcached1\')\n-    ),\n-\n ]\n \n \n@@ -308,7 +299,6 @@ def bench(participants=participants, benchmarks=benchmarks,\n def main(args=sys.argv[1:]):\n     logger.info(\'pylibmc: %s\', pylibmc.__file__)\n     logger.info(\'libmc: %s\', libmc.__file__)\n-    logger.info(\'cmemcached: %s\', cmemcached.__file__)\n \n     ps = [p for p in participants if p.name in args]\n     ps = ps if ps else participants\ndiff --git a/tests/regression_cmemcached.py b/tests/regression_cmemcached.py\ndeleted file mode 100644\nindex a6749b6..0000000\n--- a/tests/regression_cmemcached.py\n+++ /dev/null\n@@ -1,55 +0,0 @@\n-# -*- encoding:utf-8 -*-\n-\n-import cmemcached\n-import unittest\n-import cPickle as pickle\n-import marshal\n-import time\n-import threading\n-import platform\n-import pytest\n-\n-INVALID_SERVER_ADDR = \'127.0.0.1:1\'\n-\n-skip_if_libmemcached_not_patched = pytest.mark.skipif(\n-    "gentoo" not in platform.platform(),  # FIXME: better way to detect if patched?\n-    reason="need to link with libmemcached with douban\'s patches")\n-\n-\n-class TestCmemcached(unittest.TestCase):\n-\n-    @pytest.fixture(autouse=True)\n-    def setup(self, memcached):\n-        self.server_addr = memcached\n-        self.mc = cmemcached.Client([memcached], comp_threshold=1024)\n-\n-\n-        # mc=cmemcached.Client(["localhost:11999"], comp_threshold=1024)\n-        # self.assertEqual(mc.set_multi(values), 0)\n-\n-    def testGetHost(self):\n-        host = self.mc.get_host_by_key("str")\n-        self.assertEqual(host, self.server_addr)\n-\n-    def test_last_error(self):\n-        from cmemcached import RETURN_MEMCACHED_SUCCESS\n-        self.assertEqual(self.mc.set(\'testkey\', \'hh\'), True)\n-        self.assertEqual(self.mc.get(\'testkey\'), \'hh\')\n-        self.assertEqual(self.mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-        self.assertEqual(self.mc.get(\'testkey1\'), None)\n-        self.assertEqual(self.mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-        self.assertEqual(self.mc.get_multi([\'testkey\']), {\'testkey\': \'hh\'})\n-        self.assertEqual(self.mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-        self.assertEqual(self.mc.get_multi([\'testkey1\']), {})\n-        self.assertEqual(self.mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-\n-        mc = cmemcached.Client([INVALID_SERVER_ADDR], comp_threshold=1024)\n-        self.assertEqual(mc.set(\'testkey\', \'hh\'), False)\n-        self.assertEqual(mc.get(\'testkey\'), None)\n-        self.assertNotEqual(mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-        self.assertEqual(mc.get_multi([\'testkey\']), {})\n-        self.assertNotEqual(mc.get_last_error(), RETURN_MEMCACHED_SUCCESS)\n-\n-\n-if __name__ == \'__main__\':\n-    unittest.main()\ndiff --git a/tests/shabby/infinite_set_get.py b/tests/shabby/infinite_set_get.py\nindex 768ae83..b8e777d 100644\n--- a/tests/shabby/infinite_set_get.py\n+++ b/tests/shabby/infinite_set_get.py\n@@ -1,6 +1,5 @@\n import time\n from libmc import Client\n-# from cmemcached import Client\n \n \n def main():\n', 'commit_subject': 'Merge pull request #21 from mckelvin/travis', 'repo_name': 'douban/libmc', 'committer': {'name': 'zzl', 'email': '69b16de57d74919f06dfbf9680c97d438f03f0b2@gmail.com', 'time_sec': '1438585419', 'tz_offset': '480', 'date': {'seconds': '1438585419'}}, 'commit_tree': '18a93ca5fb2fd826328e134fb681dc0c20d3381f', 'commit_message': 'Merge pull request #21 from mckelvin/travis\n\nTravis-CI: Migrating from legacy to container-based infrastructure', 'language_name': 'C++', 'license': 'bsd-3-clause', 'hunks': '@@ -1,6 +1,5 @@\n import time\n from libmc import Client\n-# from cmemcached import Client\n \n \n def main():\n', 'addition_count': 0, 'deletion_count': 1, 'src_file': 'a/tests/shabby/infinite_set_get.py', 'tgt_file': 'b/tests/shabby/infinite_set_get.py', 'file_extension': '.py', 'before_file': "import time\nfrom libmc import Client\n# from cmemcached import Client\n\n\ndef main():\n    mc = Client(['127.0.0.1:%d' % (21211 + i) for i in range(10)])\n    dct = {'test_key_%d' % i: 'i' * 1000 for i in range(10)}\n    while True:\n        print '%.2f: set_multi: %r' % (time.time(), mc.set_multi(dct))\n        print '%.2f: get_multi: %r' % (\n            time.time(), mc.get_multi(dct.keys()) == dct\n        )\n        time.sleep(0.5)\n        print\n\n\nif __name__ == '__main__':\n    main()\n", 'message': 'Merge pull request #21 from mckelvin/travis\n\nTravis-CI: Migrating from legacy to container-based infrastructure', 'author_name': 'zzl', 'lang': 'py'}