Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: .NET (C#) 1.0
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
6 Retrieve Operations
Chapter Sections
Chapters

6.1. Get Methods

The Get() methods allow for direct access to a given key/value pair.

API Callobject.Get(key)
Asynchronousno
Description Get one or more key values
ReturnsObject ( Binary object )
Arguments 
string key Document ID used to identify the value
var beer = client.Get("beer") as Beer;

The generic form of the Get method allows for retrieval without the need to cast. If the stored type cannot be serialized to the generic type provided, an InvalidCastException will be thrown.

var beer = client.Get<Beer>("beer");
API Callobject.Get(keyarray)
Asynchronousno
Description Get one or more key values
ReturnsObject ( Binary object )
Arguments 
List <string> keyarray Array of keys used to reference one or more values.

Calling Get() with multiple keys returns a dictionary with the associated values.

client.Store(StoreMode.Set, "brewer", "Cottrell Brewing Co.");
client.Store(StoreMode.Set, "beer", "Old Yankee Ale");

var dict = client.Get(new string[] { "brewer", "beer" });
Console.WriteLine(dict["brewer"]);
Console.WriteLine(dict["beer"]);
API Callobject.Get(key, expiry)
Asynchronousno
Description Get a value and update the expiration time for a given key
Returns(none)
Arguments 
string key Document ID used to identify the value
object expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).

Calling the Get() method with a key and a new expiration value will cause get and touch operations to be performed.

var val = client.Get("beer", DateTime.Now.AddMinutes(5));