コード例 #1
0
        private void LoadManifest()
        {
            //The server supports collections so build them from the manifest
            if (_supportsCollections)
            {
                //warmup the scopes/collections and cache them
                foreach (var scopeDef in _manifest.scopes)
                {
                    var collections = new List <ICollection>();
                    foreach (var collectionDef in scopeDef.collections)
                    {
                        collections.Add(new CouchbaseCollection(this,
                                                                Convert.ToUInt32(collectionDef.uid), collectionDef.name));
                    }

                    _scopes.TryAdd(scopeDef.name, new Scope(scopeDef.name, scopeDef.uid, collections, this));
                }
            }
            else
            {
                //build a fake scope and collection for pre-6.5 clusters
                var defaultCollection = new CouchbaseCollection(this, null, "_default");
                var defaultScope      = new Scope("_default", "0", new List <ICollection> {
                    defaultCollection
                }, this);
                _scopes.TryAdd("_default", defaultScope);
            }
        }
コード例 #2
0
        public async Task BootstrapAsync(Uri uri, IConfiguration configuration)
        {
            _configuration = configuration;

            var ipAddress  = uri.GetIpAddress(false);
            var endPoint   = new IPEndPoint(ipAddress, 11210);
            var connection = GetConnection(endPoint);

            await Authenticate(connection);
            await Negotiate(connection);
            await GetClusterMap(connection, endPoint);

            if (_supportsCollections)
            {
                await GetManifest(connection);
            }
            else
            {
                //build a fake scope and collection for pre-6.5 clusters
                var defaultCollection = new CouchbaseCollection(this, null, "_default");
                var defaultScope      = new Scope("_default", "0", new List <ICollection> {
                    defaultCollection
                }, this);
                _scopes.TryAdd("_default", defaultScope);
            }

            Connections.AddOrUpdate(endPoint, connection, (ep, conn) => connection);
            await LoadConnections(configuration);
        }
コード例 #3
0
        protected override void LoadManifest()
        {
            //this condition should never be hit
            if (SupportsCollections)
            {
                throw new NotSupportedException("Only the default collection is supported by Memcached buckets.");
            }

            //build a fake scope and collection for Memcached buckets which do not support scopes or collections
            var defaultCollection = new CouchbaseCollection(this, null, "_default");
            var defaultScope      = new Scope("_default", "0", new List <ICollection> {
                defaultCollection
            }, this);

            Scopes.TryAdd("_default", defaultScope);
        }