Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-61

Couchbase PHP vs ext/memcached compatibility

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.3
    • 1.0
    • library
    • Security Level: Public

    Description

      Here is a sample script that demonstrates the problem:

      <?php

      // configure Memcached to talk to bejc bucket
      $mc = new Memcached();
      $mc->addServer("mem1-bjb.test.vte.customer.com", 11214);
      // configure Couchbase to talk to becj bucket
      $cb = new Couchbase("mem1-bjb.test.vte.customer.com:8091", "", "", "bejc");

      echo "Setting testKeyOne with Memcached\n";
      $mc->set("testKeyOne", "testValueOne");

      echo "Getting testKeyOne with Memcached\n";
      var_dump($mc->get("testKeyOne"));

      echo "Getting testKeyOne with Couchbase\n";
      var_dump($cb->get("testKeyOne"));

      echo "----------\n";

      echo "Setting testKeyTwo with Couchbase\n";
      $cb->set("testKeyTwo", "testValueTwo");

      echo "Getting testKeyTwo with Couchbase\n";
      var_dump($cb->get("testKeyTwo"));

      echo "Getting testKeyTwo with Memcached\n";
      var_dump($mc->get("testKeyTwo"));

      ?>

      You need to have a Couchbase server setup with a Couchbase bucket type. Alter server names and ports/buckets to match your setup.

      Save the script in a file called test.php and then run it: php test.php

      The output should look something like the following:

      Setting testKeyOne with Memcached
      Getting testKeyOne with Memcached
      string(12) "testValueOne"
      Getting testKeyOne with Couchbase
      int(0)
      ----------
      Setting testKeyTwo with Couchbase
      Getting testKeyTwo with Couchbase
      string(12) "testValueTwo"
      Getting testKeyTwo with Memcached
      NULL

      The script requires the Couchbase PHP library and the Memcached library to be installed.

      On Debian/Ubuntu you can install the Memcached library by running:

      apt-get install php5-memcached

      Because of the size of our code base we need to slowly migrate to the Couchbase library so interoperability is needed. For example while we may update the actual game code to use Couchbase it might take us a while to update the CS Tools that we use to solve customer problems.

      Attachments

        1. test.php
          1 kB
        2. test.out
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jan Jan Lehnardt (Inactive)
            perry Perry Krug
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty