Skip to content

Instantly share code, notes, and snippets.

@AndrewLane
Created March 20, 2013 16:03
Show Gist options
  • Save AndrewLane/5205889 to your computer and use it in GitHub Desktop.
Save AndrewLane/5205889 to your computer and use it in GitHub Desktop.
Showing flushing a couchbase bucket via API doesn't seem to work
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</configSections>
<couchbase>
<servers bucket="general" bucketPassword="">
<add uri="http://127.0.0.1:8091/pools"/>
</servers>
</couchbase>
</configuration>
Successfully retrieved 372f498f-f98b-4f7a-b251-d13fd826c59a
Got 372f498f-f98b-4f7a-b251-d13fd826c59a data when expecting a cache miss
using System;
using Couchbase;
using Enyim.Caching.Memcached;
namespace TryToFlushCouchbaseBucket
{
class Program
{
private static void Main(string[] args)
{
//create client object
var couchbaseClient = new CouchbaseClient("couchbase");
var randomKey = Guid.NewGuid().ToString();
var randomData = Guid.NewGuid().ToString();
//add a random key with some random data
couchbaseClient.Store(StoreMode.Set, randomKey, randomData);
var getResult = couchbaseClient.Get(randomKey);
if (getResult == null || (getResult as string) != randomData)
{
Console.WriteLine("Could not get data that I just set...");
}
else
{
Console.WriteLine("Successfully retrieved {0}", getResult);
}
//now flush the bucket
couchbaseClient.FlushAll();
//now repeat the get
getResult = couchbaseClient.Get(randomKey);
if (getResult != null)
{
Console.WriteLine("Got {0} data when expecting a cache miss", getResult);
}
else
{
Console.WriteLine("Flush seemed to work");
}
Environment.Exit(0);
}
}
}
@karwanjafi
Copy link

Hi. have you been found any solution for this? I can't flush too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment