Today we’re releasing version 2.3.10 of the Couchbase .NET SDK. This is a maintenance release of bug fixes and enhancements including the Data Structures API and FTS API. In case you missed it, we have a Developer Preview of .NET Core support here.
New Features and Changes
We follow semantic versioning, meaning we increment the dot-minor number when adding features. We sometimes add low-risk features in maintenance releases with uncommitted interface stability so you as a developer can easily gain access to new features. Features added under in a maintenance release are uncommitted and are open to change but should be promoted to committed in the next dot-minor release.
See here for a discussion of interface in the .NET SDK.
Data Structures API update
When we introduced the Data Structures API in the 2.3.9 release we added support for lists, maps and dictionaries. In this release we’re also adding support for Queues. This enables you to use a JSON document stored in Couchbase to maintain an ordered FIFO queue, with all the normal concurrency control you would expect from an in-memory queue. An example on how to use a queue is below:
1 2 3 4 5 6 |
bucket.QueuePush("my_queue", new Person("Jerry")); bucket.QueuePush("my_queue", new Person("Rodney")); var size = bucket.QueueSize("my_queue"); // 2 var person = bucket.QueuePop("my_Queue"); // Jerry |
Also, as part of the refinement of the uncommitted Data Structures API we have updated some method names to be consistent across all the Couchbase SDKs. The changes are below:
Old | New |
---|---|
ListPush | ListAppend |
ListShift | ListPrepend |
ListDelete | ListRemove |
SetExists | SetContains |
Sorting FTS results
An enhancement to the FTS (Full-Text Search) capabilities of Couchbase Server 4.6 is to allow the user to apply their own sorting preferences on the server before returning the result. This is done using the Sort method on ISearchParams before submitting a search. There can be one or more sorting fields, and fields that are prefixed with a dash indicate a descending order.
1 2 3 |
var searchParams = new SearchParams(); searchParams.Sort("name", "-age"); |
The above example sort criteria indicates to sort by ascending name then by descending age.
Waiting for N1QL indexes
The SDK enables you as a developer to create N1QL indexes programmatically. However, indexes are created in an asynchronous manner on the server and executing queries against incomplete indexes is a bad idea. As part of this release we have introduced a way for the SDK to watch and wait for one or more indexes to go into the ‘online’ state before continuing. An example of creating an index and waiting for it to be online is below:
1 2 3 4 5 6 7 |
// Create index called "accounts" on columns "account_id" and "account_name" bucketManager.CreateN1qlIndex("accounts", false, "account_id", "account_name"); // Wait for the index to be marked as 'online', with a 30 second timeout var indexNames = new List { "accounts" }; bucketManager.WatchN1qlIndexes(indexNames, TimeSpan.FromSeconds(30)); |
Release Notes
- [NCBC-1104] – When SSL certificate is not setup correctly System.ArgumentException is thrown.
- [NCBC-1232] – NET client may not automatically re-prepare when an index is removed
- [NCBC-1233] – 2.3.9 assembly is not strongly named and does not have a publicKeyToken
- [NCBC-1236] – DotMemory unresolved reference from IntegrationTests
- [NCBC-1079] – streaming JSON parser for N1QL
- [NCBC-1204] – should use interface for Buckets property
- [NCBC-1237] – custom “sort” param for FTS
- [NCBC-1227] – QueuePush, QueuePop, and QueueSize to IBucket
- [NCBC-1036] – Create writeup on how to provision a cluster programmatically with code sample
- [NCBC-1101] – WatchIndexes for index managment
How to Get It
As always, the Couchbase .NET SDK is available on/by: