Skip to content

Instantly share code, notes, and snippets.

View MikeGoldsmith's full-sized avatar

Mike Goldsmith MikeGoldsmith

View GitHub Profile
@MikeGoldsmith
MikeGoldsmith / example-pools.json
Last active November 22, 2017 21:08
Example JSON structure returned from CB /pools/default endpoint
{
"storageTotals":{
"ram":{
"total":1042685952,
"quotaTotal":268435456,
"quotaUsed":171966464,
"used":975515648,
"usedByData":21565232,
"quotaUsedPerNode":171966464,
"quotaTotalPerNode":268435456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Couchbase;
using Couchbase.Configuration.Client;
using Couchbase.Core;
using Couchbase.IO;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Couchbase;
using Couchbase.Authentication;
using Couchbase.Configuration.Client;
namespace memcached_example
{
class Program
{
INFO:couchbase:Initializing Couchbase logging. lcb_version=('2.7.5', 132869)
DEBUG:couchbase.confmon:[0] Preparing providers (this may be called multiple times) (L:83)
DEBUG:couchbase.confmon:[0] Provider CCCP is ENABLED (L:90)
DEBUG:couchbase.confmon:[0] Provider HTTP is ENABLED (L:90)
DEBUG:couchbase.confmon:[0] Refreshing current cluster map (L:252)
DEBUG:couchbase.confmon:[0] Attempting to retrieve cluster map via CCCP (L:239)
INFO:couchbase.cccp:[0] Requesting connection to node 10.112.170.101:11210 for CCCP configuration (L:149)
DEBUG:couchbase.lcbio_mgr:[0] <10.112.170.101:11210> (HE=0x7fba65f2ee80) Creating new connection because none are available in the pool (L:408)
DEBUG:couchbase.lcbio_mgr:[0] <10.112.170.101:11210> (HE=0x7fba65f2ee80) New pool entry: I=0x7fba65f2efd0 (L:323)
INFO:couchbase.connection:[0] <10.112.170.101:11210> (SOCK=0x7fba65e4c0f0) Starting. Timeout=2000000us (L:465)
[Test]
public async Task Test_Enhanced_Error_Messages()
{
// boostrap client
var config = TestConfiguration.GetConfiguration("basic");
config.BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{"default", new BucketConfiguration {UseKvErrorMap = true}}
};
@MikeGoldsmith
MikeGoldsmith / mutliget_async.cs
Last active July 21, 2017 12:22
example of doing async multi get
static void Main(string[] args)
{
var config = new ClientConfiguration {Servers = new List<Uri> {new Uri("http://10.112.170.191")}};
using (var cluster = new Cluster(config))
{
var bucket = cluster.OpenBucket("default");
var keys = new List<string>
{
"test1", "test2", "test3"
MemcachedBinprotConnection connection(
"127.0.0.1",
11210,
AF_INET,
false);
connection.authenticate("trond", "password", "PLAIN");
connection.hello("rbac_demo", MEMCACHED_VERSION, "RBAC demo code");
connection.setXerrorSupport(true);
@MikeGoldsmith
MikeGoldsmith / ketama-ring-hashes.json
Created February 10, 2017 14:11
Hashes/hostname list to be used to verify Ketama hash algorithm
[
{
"hash": 19069626,
"hostname": "192.168.1.104:11210"
},
{
"hash": 28439255,
"hostname": "192.168.1.101:11210"
},
{
using (var md5 = MD5.Create())
{
foreach (var server in _servers.Values.Where(x => x.IsDataNode))
{
const long repititions = 40;
for (long rep = 0; rep < repititions; rep++)
{
var bytes = Encoding.UTF8.GetBytes(string.Format("{0}-{1}", server.EndPoint, rep));
var hash = md5.ComputeHash(bytes);
for (var j = 0; j < 4; j++)
var query = new SearchQuery
{
Query = new PhraseQuery("inn").Field("name"),
Index = "idx_travel"
};
query.Skip(0).Limit(10).Timeout(TimeSpan.FromSeconds(10));
var result = bucket.Query(query);
foreach (var row in result.Hits)
{