HowTo use Couchbase.Upsert and pass a server param


#1

Hi, I have successfully implemented couchbase caching using Upsert but i now need to “mark” each cached record with the environment the caching is running on.
My implementation is on the same load balanced cluster for multiple environments and the problem i am currently facing is the cache is available on ALL environments even though it was created on a certain env.
Example.

Create cache on Env 1. (Saves to global Load Balanced Couchbase server)
Retrieve cache on Env 1.

Cache is also available on Env 2 using the same Couchbase server.

This is my working C# code.

private IBucket GetBucket()
{
     var cb = new Cluster(_config.GetConfigValue("CouchbaseCluster"));
     return cb.OpenBucket();
}

GetBucket().Upsert("Key","Value", timeoutValue);

Is there an additional param on the upsert command to indicate the environment maybe?
Thanks


#2

@timsfcuk -

There is no parameter to “mark” the evironment, however, you could add a field to your JSON document that indicates the environment it belongs to. Another approach is to use a key which indicates the environment it exists on and then use some parsing on the app side to generate the correct key given the environment. Something like: “envX:person:2”