Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Expected behaviour of ExecuteGet?

1 reply [Last post]
  • Login or register to post comments
Wed, 11/28/2012 - 04:01
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

Reposting here from Couchbase 1.8 forum:

Using the .NET v1.1.6 client against Couchbase 1.8.1, I'm getting surprising results from the new ExecuteGet() method

var key = Guid.NewGuid().ToString();
var result = client.ExecuteGet(key); // Doesn't exists
 
Console.WriteLine(result.Success); // false
Console.WriteLine(result.Message); // Unable to locate node
Console.WriteLine(result.Value); // null
 
client.Store(StoreMode.Set, key, "blah"); // Adding it
result = client.ExecuteGet(key); // Does exist
 
Console.WriteLine(result.Success); // true
Console.WriteLine(result.Message); // null
Console.WriteLine(result.Value); // blah

Is this behaviour by design? It seems that it isn't possible to distinguish between a network failure and a key that doesn't currently exist. In the case of a non-existent key, my expectation would be that Success == true but Value == null.

UPDATE: I checked out the master branch of couchbase-dot-net client repo and I can see that the test

CouchbaseClientGetTests.When_Getting_Item_For_Invalid_Key_HasValue_Is_False_And_Result_Is_Not_Successful

is passing and correctly setting a status code of 1 (StatusCodeEnums.NotFound). This makes a lot more sense. The problem is I don't get this same behaviour for my client (v1.1.6). I also can't seem to be able to get the release11 branch of couchbase-dot-net to compile due to differences in the Enyim client.

Top
  • Login or register to post comments
Wed, 11/28/2012 - 05:24
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

OK, I got the release11 branch working against a binary Enyim reference. The test still passes, but the result.Message is now "Unable to locate node" and the Status code is null (as it is for my version). The reason the test passes is that the assertions are quite loose:

protected void GetAssertFail(IGetOperationResult result)
{
	Assert.That(result.Success, Is.False, "Success was true");
	Assert.That(result.Cas, Is.EqualTo(0), "Cas value was not 0");
	Assert.That(result.StatusCode, Is.Null.Or.GreaterThan(0), "StatusCode not greater than 0");
	Assert.That(result.HasValue, Is.False, "HasValue was true");
	Assert.That(result.Value, Is.Null, "Value was not null");
}

So it seems that this is something that is improved in the latest version of the client. Any plans to release another 1.1.* version soon?

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker