当前位置: 首页>>代码示例>>C#>>正文


C# Client.AerospikeClient类代码示例

本文整理汇总了C#中Aerospike.Client.AerospikeClient的典型用法代码示例。如果您正苦于以下问题:C# AerospikeClient类的具体用法?C# AerospikeClient怎么用?C# AerospikeClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AerospikeClient类属于Aerospike.Client命名空间,在下文中一共展示了AerospikeClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunExample

        /// <summary>
        /// Demonstrate multiple operations on a single record in one call.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            // Write initial record.
            Key key = new Key(args.ns, args.set, "opkey");
            Bin bin1 = new Bin("optintbin", 7);
            Bin bin2 = new Bin("optstringbin", "string value");
            console.Info("Put: namespace={0} set={1} key={2} binname1={3} binvalue1={4} binname1={5} binvalue1={6}",
                key.ns, key.setName, key.userKey, bin1.name, bin1.value, bin2.name, bin2.value);
            client.Put(args.writePolicy, key, bin1, bin2);

            // Add integer, write new string and read record.
            Bin bin3 = new Bin(bin1.name, 4);
            Bin bin4 = new Bin(bin2.name, "new string");
            console.Info("Add: " + bin3.value);
            console.Info("Write: " + bin4.value);
            console.Info("Read:");
            Record record = client.Operate(args.writePolicy, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get());

            if (record == null)
            {
                throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
                    key.ns, key.setName, key.userKey));
            }

            ValidateBin(key, record, bin3.name, 11L, record.GetValue(bin3.name));
            ValidateBin(key, record, bin4.name, bin4.value.ToString(), record.GetValue(bin4.name));
        }
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:30,代码来源:Operate.cs

示例2: generateCustomerProduct

        public static void generateCustomerProduct(AerospikeClient client)
        {
            Random products = new Random (2727);
            Random productsPerAccount = new Random (9898);
            Random productQuantity = new Random (1919);
            for (int i = 0; i < accountTotal; i++) {

                int productsToAdd = productsPerAccount.Next (1, 150);
                string keyString = i.ToString ();
                Key cdtkey = new Key (ns, cdtSet, keyString);
                Aerospike.Helper.Collection.LargeList clist = new Aerospike.Helper.Collection.LargeList (client, null, cdtkey, cdtBinName);
                Key ldtkey = new Key (ns, ldtSet, keyString);
                LargeList llist = client.GetLargeList (null, ldtkey, ldtBinName);

                //for diagnositics
                client.Put (null, cdtkey, new Bin (keyBinName, keyString), new Bin (accBinName, keyString));
                client.Put (null, ldtkey, new Bin (keyBinName, keyString), new Bin (accBinName, keyString));

                for (int j = 0; j < productsToAdd; j++) {
                    int product = products.Next (1, productTotal);
                    int productAmount = productQuantity.Next (1, 100);
                    Value value = makeValue (product, productAmount);

                    llist.Update (value);
                    clist.Update (value);

                }
            }
        }
开发者ID:helipilot50,项目名称:Aerospike-list-expansion,代码行数:29,代码来源:Program.cs

示例3: RunExample

        /// <summary>
        /// Batch multiple gets in one call to the server.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            string keyPrefix = "batchkey";
            string valuePrefix = "batchvalue";
            string binName = args.GetBinName("batchbin");
            int size = 8;

            WriteRecords(client, args, keyPrefix, binName, valuePrefix, size);
            BatchExists(client, args, keyPrefix, size);
            BatchReads(client, args, keyPrefix, binName, size);
            BatchReadHeaders(client, args, keyPrefix, size);

            try
            {
                BatchReadComplex(client, args, keyPrefix, binName);
            }
            catch (Exception ex)
            {
                // Server version may not yet support new batch protocol.
                Node[] nodes = client.Nodes;

                foreach (Node node in nodes)
                {
                    if (!node.HasBatchIndex)
                    {
                        Log.Warn("Server does not support new batch protocol");
                        return;
                    }
                }
                throw ex;
            }
        }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:35,代码来源:Batch.cs

示例4: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Establish connection the server
            try
            {
                AerospikeClient client = new AerospikeClient("45.55.231.46", 3000);

                // Create key
                Aerospike.Client.Key key = new Aerospike.Client.Key("test", "myset", "mykey");

                // Create Bins
                Bin bin1 = new Bin("name", "John");
                Bin bin2 = new Bin("age", 25);

                // Write record
                client.Put(null, key, bin1, bin2);

                // Read record
                Record record = client.Get(null, key);

                Record userRecord = client.Get(null, key);
                Console.WriteLine("Info:");
                Console.WriteLine("Name: " + userRecord.GetValue("name"));
                Console.WriteLine("Age: " + userRecord.GetValue("age"));

                // Close connection
                client.Close();
            }
            catch (AerospikeException.Connection conError)
            {
                Console.Write(conError);
            }
        }
开发者ID:bohregard,项目名称:SampleCsAeroSpike,代码行数:33,代码来源:MainWindow.xaml.cs

示例5: TestArray

        /// <summary>
        /// Write array of integers using standard C# serializer.
        /// </summary>
        public virtual void TestArray(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "serialarraykey");

            // Delete record if it already exists.
            client.Delete(args.writePolicy, key);

            console.Info("Initialize array");

            int[] array = new int[10000];

            for (int i = 0; i < 10000; i++)
            {
                array[i] = i * i;
            }

            Bin bin = new Bin(args.GetBinName("serialbin"), (object)array);

            // Do a test that pushes this complex object through the serializer
            console.Info("Write array using serializer.");
            client.Put(args.writePolicy, key, bin);

            console.Info("Read array using serializer.");
            Record record = client.Get(args.policy, key, bin.name);

            if (record == null)
            {
                throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
                    key.ns, key.setName, key.userKey));
            }

            int[] received;

            try
            {
                received = (int[])record.GetValue(bin.name);
            }
            catch (Exception)
            {
                throw new Exception(string.Format("Failed to parse returned value: namespace={0} set={1} key={2} bin={3}",
                    key.ns, key.setName, key.userKey, bin.name));
            }

            if (received.Length != 10000)
            {
                throw new Exception(string.Format("Array length mismatch: Expected={0:D} Received={1:D}",
                    10000, received.Length));
            }

            for (int i = 0; i < 10000; i++)
            {
                if (received[i] != i * i)
                {
                    throw new Exception(string.Format("Mismatch: index={0:D} expected={1:D} received={2:D}",
                        i, i * i, received[i]));
                }
            }

            console.Info("Read array successful.");
        }
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:63,代码来源:Serialize.cs

示例6: RunSimpleExample

        public void RunSimpleExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "listkey");
            string binName = args.GetBinName("listbin");

            // Delete record if it already exists.
            client.Delete(args.writePolicy, key);

            IList inputList = new List<Value>();
            inputList.Add(Value.Get(55));
            inputList.Add(Value.Get(77));

            // Write values to empty list.
            Record record = client.Operate(args.writePolicy, key, ListOperation.AppendItems(binName, inputList));

            console.Info("Record: " + record);

            // Pop value from end of list and also return new size of list.
            record = client.Operate(args.writePolicy, key, ListOperation.Pop(binName, -1), ListOperation.Size(binName));

            console.Info("Record: " + record);

            // There should be one result for each list operation on the same list bin.
            // In this case, there are two list operations (pop and size), so there
            // should be two results.
            IList list = record.GetList(binName);

            foreach (object value in list)
            {
                console.Info("Received: " + value);
            }
        }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:32,代码来源:OperateList.cs

示例7: RoleEditForm

        public RoleEditForm(AerospikeClient client, EditType editType, RoleRow row)
        {
            this.client = client;
            this.editType = editType;
            InitializeComponent();

            grid.AutoGenerateColumns = false;
            PrivilegeCodeColumn.DataPropertyName = "Code";
            PrivilegeCodeColumn.ValueMember = "PrivilegeCode";
            PrivilegeCodeColumn.DisplayMember = "Label";
            PrivilegeCodeColumn.DataSource = GetPrivilegeTypeBinding();
            NamespaceColumn.DataPropertyName = "Namespace";
            SetNameColumn.DataPropertyName = "SetName";

            BindingSource bindingSource = new BindingSource();

            switch (editType)
            {
                case EditType.CREATE:
                    bindingSource.DataSource = new BindingList<Privilege>();
                    break;

                case EditType.EDIT:
                    this.Text = "Edit Role";
                    nameBox.Enabled = false;
                    nameBox.Text = row.name;
                    bindingSource.DataSource = LoadPrivileges(row.privileges);
                    oldPrivileges = row.privileges;
                    break;
            }
            grid.DataSource = bindingSource;
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:32,代码来源:RoleEditForm.cs

示例8: LargeList

 /// <summary>
 /// Initialize large list operator.
 /// </summary>
 /// <param name="client">client</param>
 /// <param name="policy">generic configuration parameters, pass in null for defaults</param>
 /// <param name="key">unique record identifier</param>
 /// <param name="binName">bin name</param>
 public LargeList(AerospikeClient client, WritePolicy policy, Key key, string binName)
 {
     this.client = client;
     this.policy = policy;
     this.key = key;
     this.binName = Value.Get(binName);
 }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:14,代码来源:LargeList.cs

示例9: RunExample

        /// <summary>
        /// Demonstrate writing bins with replace option. Replace will cause all record bins
        /// to be overwritten.  If an existing bin is not referenced in the replace command,
        /// the bin will be deleted.
        /// <para>
        /// The replace command has a performance advantage over the default put, because 
        /// the server does not have to read the existing record before overwriting it.
        /// </para>
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            // Write securities
            console.Info("Write securities");
            Security security = new Security("GE", 26.89);
            security.Write(client, args.writePolicy, args.ns, args.set);

            security = new Security("IBM", 183.6);
            security.Write(client, args.writePolicy, args.ns, args.set);

            // Write account with positions.
            console.Info("Write account with positions");
            List<Position> positions = new List<Position>(2);
            positions.Add(new Position("GE", 1000));
            positions.Add(new Position("IBM", 500));
            Account accountWrite = new Account("123456", positions);
            accountWrite.Write(client, args.writePolicy, args.ns, args.set);

            // Read account/positions and join with securities.
            console.Info("Read accounts, positions and securities");
            Account accountRead = new Account();
            accountRead.Read(client, null, args.ns, args.set, "123456");

            // Validate data
            accountWrite.Validate(accountRead);
            console.Info("Accounts match");
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:36,代码来源:GetAndJoin.cs

示例10: RunExample

 /// <summary>
 /// Query server configuration, cluster status and namespace configuration.
 /// </summary>
 public override void RunExample(AerospikeClient client, Arguments args)
 {
     Node node = client.Nodes[0];
     GetServerConfig(node, args);
     console.Write("");
     GetNamespaceConfig(node, args);
 }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:10,代码来源:ServerInfo.cs

示例11: infoAll

 public static String infoAll(AerospikeClient client, String cmd)
 {
     StringBuilder results = new StringBuilder();
     foreach (Node node in client.Nodes){
         results.Append(Info.Request(node.Host.name, node.Host.port, cmd)).Append("\n");
     }
     return results.ToString();
 }
开发者ID:helipilot50,项目名称:aerospike-helper,代码行数:8,代码来源:Utils.cs

示例12: CheckKeyExists

 private static void CheckKeyExists(AerospikeClient client, Policy policy,
         Key key)
 {
     Console.WriteLine("Check a record exists");
     var exists = client.Exists(policy, key);
     Console.WriteLine(key + " exists? " + exists);
     Console.WriteLine("");
 }
开发者ID:jamesrcounts,项目名称:areospike-client-demo-net,代码行数:8,代码来源:Program.cs

示例13: DeleteRecords

 private void DeleteRecords(AerospikeClient client, Arguments args, string keyPrefix, int size)
 {
     for (int i = 0; i < size; i++)
     {
         Key key = new Key(args.ns, args.set, keyPrefix + i);
         client.Delete(args.writePolicy, key);
     }
 }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:8,代码来源:QueryGeoCollection.cs

示例14: LargeSet

 /// <summary>
 /// Initialize large set operator.
 /// </summary>
 /// <param name="client">client</param>
 /// <param name="policy">generic configuration parameters, pass in null for defaults</param>
 /// <param name="key">unique record identifier</param>
 /// <param name="binName">bin name</param>
 /// <param name="createModule">Lua function name that initializes list configuration parameters, pass null for default set</param>
 public LargeSet(AerospikeClient client, WritePolicy policy, Key key, string binName, string createModule)
 {
     this.client = client;
     this.policy = policy;
     this.key = key;
     this.binName = Value.Get(binName);
     this.createModule = Value.Get(createModule);
 }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:16,代码来源:LargeSet.cs

示例15: RunExample

        /// <summary>
        /// Add integer values.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "addkey");
            string binName = args.GetBinName("addbin");

            // Delete record if it already exists.
            client.Delete(args.writePolicy, key);

            // Perform some adds and check results.
            Bin bin = new Bin(binName, 10);
            console.Info("Initial add will create record.  Initial value is " + bin.value + '.');
            client.Add(args.writePolicy, key, bin);

            bin = new Bin(binName, 5);
            console.Info("Add " + bin.value + " to existing record.");
            client.Add(args.writePolicy, key, bin);

            Record record = client.Get(args.policy, key, bin.name);

            if (record == null)
            {
                throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
                    key.ns, key.setName, key.userKey));
            }

            // The value received from the server is an unsigned byte stream.
            // Convert to an integer before comparing with expected.
            int received = record.GetInt(bin.name);
            int expected = 15;

            if (received == expected)
            {
                console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}",
                    key.ns, key.setName, key.userKey, bin.name, received);
            }
            else
            {
                console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received);
            }

            // Demonstrate add and get combined.
            bin = new Bin(binName, 30);
            console.Info("Add " + bin.value + " to existing record.");
            record = client.Operate(args.writePolicy, key, Operation.Add(bin), Operation.Get(bin.name));

            expected = 45;
            received = record.GetInt(bin.name);

            if (received == expected)
            {
                console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}",
                    key.ns, key.setName, key.userKey, bin.name, received);
            }
            else
            {
                console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received);
            }
        }
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:61,代码来源:Add.cs


注:本文中的Aerospike.Client.AerospikeClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。