Search:

Search all manuals
Search this manual
Manual
Couchbase Developer's Guide 1.8
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
3 Creating Your First Application
Chapter Sections
Chapters

3.3. Performing Connect, Set and Get

The following example demonstrates connecting, setting, then getting a record:

<?php

$cb = new Couchbase(”host:8091", "bucket", "pass", "bucket");

$cb->set("hello", "Hello World");

var_dump($cb->get("hello"));

?>

The same pattern would be used in any given SDK: connect, then perform a set with key/value, and within the same connection, get and output the new value.

require 'rubygems'
    require 'couchbase'

    client = Couchbase.connect "http://<host>:8091/pools/default"
    client.set "new", "Test content", :ttl => 20
    rec = client.get "new"

    if(rec)
      puts rec
    else
      puts "no record"
    end