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


C# AerospikeClient.Delete方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: RunExample

        /// <summary>
        /// Perform operations on a list within a single bin.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            if (!args.hasLargeDataTypes)
            {
                console.Info("Large set functions are not supported by the connected Aerospike server.");
                return;
            }

            Key key = new Key(args.ns, args.set, "setkey");
            string binName = args.GetBinName("setbin");

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

            // Initialize large set operator.
            Aerospike.Client.LargeSet set = client.GetLargeSet(args.writePolicy, key, binName, null);

            // Write values.
            set.Add(Value.Get("setvalue1"));
            set.Add(Value.Get("setvalue2"));
            set.Add(Value.Get("setvalue3"));

            // Verify large set was created with default configuration.
            IDictionary map = set.GetConfig();

            foreach (DictionaryEntry entry in map)
            {
                console.Info(entry.Key.ToString() + ',' + entry.Value);
            }

            // Remove last value.
            set.Remove(Value.Get("setvalue3"));

            int size = set.Size();

            if (size != 2)
            {
                throw new Exception("Size mismatch. Expected 2 Received " + size);
            }

            string received = (string)set.Get(Value.Get("setvalue2"));
            string expected = "setvalue2";

            if (received != null && received.Equals(expected))
            {
                console.Info("Data matched: namespace={0} set={1} key={2} value={3}", key.ns, key.setName, key.userKey, received);
            }
            else
            {
                console.Error("Data mismatch: Expected {0}. Received {1}.", expected, received);
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:55,代码来源:LargeSet.cs

示例6: RunScoreExample

        public void RunScoreExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "mapkey");
            string binName = args.GetBinName("mapbin");

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

            IDictionary inputMap = new Dictionary<Value, Value>();
            inputMap[Value.Get("Charlie")] = Value.Get(55);
            inputMap[Value.Get("Jim")] = Value.Get(98);
            inputMap[Value.Get("John")] = Value.Get(76);
            inputMap[Value.Get("Harry")] = Value.Get(82);

            // Write values to empty map.
            Record record = client.Operate(args.writePolicy, key,
                MapOperation.PutItems(MapPolicy.Default, binName, inputMap)
                );

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

            // Increment some user scores.
            record = client.Operate(args.writePolicy, key,
                MapOperation.Increment(MapPolicy.Default, binName, Value.Get("John"), Value.Get(5)),
                MapOperation.Decrement(MapPolicy.Default, binName, Value.Get("Jim"), Value.Get(4))
                );

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

            // Get top two scores.
            record = client.Operate(args.writePolicy, key,
                MapOperation.GetByRankRange(binName, -2, 2, MapReturnType.KEY_VALUE)
                );

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

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

示例7: RunExample

        /// <summary>
        /// Prepend string to an existing string.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "prependkey");
            string binName = args.GetBinName("prependbin");

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

            Bin bin = new Bin(binName, "World");
            console.Info("Initial prepend will create record.  Initial value is " + bin.value + '.');
            client.Prepend(args.writePolicy, key, bin);

            bin = new Bin(binName, "Hello ");
            console.Info("Prepend \"" + bin.value + "\" to existing record.");
            client.Prepend(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.
            object received = record.GetValue(bin.name);
            string expected = "Hello World";

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

示例8: TestListCompoundList

        /// <summary>
        /// Write/Read list of compound objects using Aerospike list type with blob entries (Bin.AsList()).
        /// </summary>
        private void TestListCompoundList(AerospikeClient client, Arguments args)
        {
            console.Info("Read/Write ArrayList<CompoundObject> using list with blob entries");
            Key key = new Key(args.ns, args.set, "listkey5");
            client.Delete(args.writePolicy, key);

            List<CompoundObject> list = new List<CompoundObject>();
            list.Add(new CompoundObject("string1", 7));
            list.Add(new CompoundObject("string2", 9));
            list.Add(new CompoundObject("string3", 54));

            Bin bin = new Bin("listbin", list);
            client.Put(args.writePolicy, key, bin);

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

            ValidateSize(3, receivedList.Count);
            Validate(list[0], receivedList[0]);
            Validate(list[1], receivedList[1]);
            Validate(list[2], receivedList[2]);

            console.Info("Read/Write ArrayList<CompoundObject> successful.");
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:27,代码来源:ListMap.cs

示例9: RunExample

        /// <summary>
        /// Exercise record generation functionality.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "genkey");
            string binName = args.GetBinName("genbin");

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

            // Set some values for the same record.
            Bin bin = new Bin(binName, "genvalue1");
            console.Info("Put: namespace={0} set={1} key={2} bin={3} value={4}",
                key.ns, key.setName, key.userKey, bin.name, bin.value);

            client.Put(args.writePolicy, key, bin);

            bin = new Bin(binName, "genvalue2");
            console.Info("Put: namespace={0} set={1} key={2} bin={3} value={4}",
                key.ns, key.setName, key.userKey, bin.name, bin.value);

            client.Put(args.writePolicy, key, bin);

            // Retrieve record and its generation count.
            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));
            }

            object received = record.GetValue(bin.name);
            string expected = bin.value.ToString();

            if (received.Equals(expected))
            {
                console.Info("Get successful: namespace={0} set={1} key={2} bin={3} value={4} generation={5}",
                    key.ns, key.setName, key.userKey, bin.name, received, record.generation);
            }
            else
            {
                throw new Exception(string.Format("Get mismatch: Expected {0}. Received {1}.", expected, received));
            }

            // Set record and fail if it's not the expected generation.
            bin = new Bin(binName, "genvalue3");
            console.Info("Put: namespace={0} set={1} key={2} bin={3} value={4} expected generation={5}",
                key.ns, key.setName, key.userKey, bin.name, bin.value, record.generation);

            WritePolicy writePolicy = new WritePolicy();
            writePolicy.generationPolicy = GenerationPolicy.EXPECT_GEN_EQUAL;
            writePolicy.generation = record.generation;
            client.Put(writePolicy, key, bin);

            // Set record with invalid generation and check results .
            bin = new Bin(binName, "genvalue4");
            writePolicy.generation = 9999;
            console.Info("Put: namespace={0} set={1} key={2} bin={3} value={4} expected generation={5}",
                key.ns, key.setName, key.userKey, bin.name, bin.value, writePolicy.generation);

            try
            {
                client.Put(writePolicy, key, bin);
                throw new Exception("Should have received generation error instead of success.");
            }
            catch (AerospikeException ae)
            {
                if (ae.Result == ResultCode.GENERATION_ERROR)
                {
                    console.Info("Success: Generation error returned as expected.");
                }
                else
                {
                    throw new Exception(string.Format("Unexpected set return code: namespace={0} set={1} key={2} bin={3} value={4} code={5}",
                        key.ns, key.setName, key.userKey, bin.name, bin.value, ae.Result));
                }
            }

            // Verify results.
            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));
            }

            received = record.GetValue(bin.name);
            expected = "genvalue3";

            if (received.Equals(expected))
            {
                console.Info("Get successful: namespace={0} set={1} key={2} bin={3} value={4} generation={5}",
                    key.ns, key.setName, key.userKey, bin.name, received, record.generation);
            }
            else
            {
                throw new Exception(string.Format("Get mismatch: Expected {0}. Received {1}.", expected, received));
//.........这里部分代码省略.........
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:101,代码来源:Generation.cs

示例10: TestListMapCombined

        /// <summary>
        /// Write/Read List/HashMap combination directly instead of relying on default serializer.
        /// </summary>
        private void TestListMapCombined(AerospikeClient client, Arguments args)
        {
            console.Info("Read/Write List/HashMap");
            Key key = new Key(args.ns, args.set, "listmapkey");
            client.Delete(args.writePolicy, key);

            byte[] blob = new byte[] {3, 52, 125};
            List<object> inner = new List<object>();
            inner.Add("string2");
            inner.Add(5);

            Dictionary<object, object> innerMap = new Dictionary<object, object>();
            innerMap["a"] = 1;
            innerMap[2] = "b";
            innerMap[3] = blob;
            innerMap["list"] = inner;

            List<object> list = new List<object>();
            list.Add("string1");
            list.Add(8);
            list.Add(inner);
            list.Add(innerMap);

            Bin bin = new Bin(args.GetBinName("listmapbin"), list);
            client.Put(args.writePolicy, key, bin);

            Record record = client.Get(args.policy, key, bin.name);
            List<object> received = (List<object>) record.GetValue(bin.name);

            ValidateSize(4, received.Count);
            Validate("string1", received[0]);
            // Server convert numbers to long, so must expect long.
            Validate(8L, received[1]);

            List<object> receivedInner = (List<object>)received[2];
            ValidateSize(2, receivedInner.Count);
            Validate("string2", receivedInner[0]);
            Validate(5L, receivedInner[1]);

            Dictionary<object, object> receivedMap = (Dictionary<object, object>)received[3];
            ValidateSize(4, receivedMap.Count);
            Validate(1L, receivedMap["a"]);
            Validate("b", receivedMap[2L]);
            Validate(blob, (byte[])receivedMap[3L]);

            List<object> receivedInner2 = (List<object>)receivedMap["list"];
            ValidateSize(2, receivedInner2.Count);
            Validate("string2", receivedInner2[0]);
            Validate(5L, receivedInner2[1]);

            console.Info("Read/Write List/HashMap successful");
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:55,代码来源:ListMap.cs

示例11: RunSimpleExample

        /// <summary>
        /// Simple examples of large list functionality.
        /// </summary>
        private void RunSimpleExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "setkey");
            string binName = args.GetBinName("ListBin");

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

            // Initialize large set operator.
            Aerospike.Client.LargeList llist = client.GetLargeList(args.writePolicy, key, binName);
            string orig1 = "llistValue1";
            string orig2 = "llistValue2";
            string orig3 = "llistValue3";

            // Write values.
            llist.Add(Value.Get(orig1));
            llist.Add(Value.Get(orig2));
            llist.Add(Value.Get(orig3));

            IDictionary map = llist.GetConfig();

            foreach (DictionaryEntry entry in map)
            {
                console.Info(entry.Key.ToString() + ',' + entry.Value);
            }

            IList rangeList = llist.Range(Value.Get(orig2), Value.Get(orig3));

            if (rangeList == null)
            {
                throw new Exception("Range returned null.");
            }

            if (rangeList.Count != 2)
            {
                throw new Exception("Range Size mismatch. Expected 2 Received " + rangeList.Count);
            }
            string v2 = (string) rangeList[0];
            string v3 = (string) rangeList[1];

            if (v2.Equals(orig2) && v3.Equals(orig3))
            {
                console.Info("Range Query matched: v2=" + orig2 + " v3=" + orig3);
            }
            else
            {
                throw new Exception("Range Content mismatch. Expected (" + orig2 + ":" + orig3 +
                    ") Received (" + v2 + ":" + v3 + ")");
            }

            // Remove last value.
            llist.Remove(Value.Get(orig3));

            int size = llist.Size();

            if (size != 2)
            {
                throw new Exception("Size mismatch. Expected 2 Received " + size);
            }

            IList listReceived = llist.Find(Value.Get(orig2));
            string expected = orig2;

            if (listReceived == null)
            {
                console.Error("Data mismatch: Expected " + expected + " Received null");
                return;
            }

            string stringReceived = (string) listReceived[0];

            if (stringReceived != null && stringReceived.Equals(expected))
            {
                console.Info("Data matched: namespace=" + key.ns + " set=" + key.setName + " key=" + key.userKey +
                    " value=" + stringReceived);
            }
            else
            {
                console.Error("Data mismatch: Expected " + expected + " Received " + stringReceived);
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:84,代码来源:LargeList.cs

示例12: RunWithSerializedBin

        /// <summary>
        /// Use serialized bin for row in largelist bin. 
        /// </summary>
        private void RunWithSerializedBin(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "accountId");

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

            // Initialize large list operator.
            Aerospike.Client.LargeList list = client.GetLargeList(args.writePolicy, key, "trades");

            // Write trades
            Dictionary<string, Value> dict = new Dictionary<string, Value>();
            MemoryStream ms = new MemoryStream(500);

            DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43);
            dict["key"] = Value.Get(timestamp1.Ticks);
            BinaryWriter writer = new BinaryWriter(ms);
            writer.Write("IBM");  // ticker
            writer.Write(100);    // qty
            writer.Write(181.82); // price
            dict["value"] = Value.Get(ms.ToArray());
            list.Add(Value.Get(dict));

            DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17);
            dict["key"] = Value.Get(timestamp2.Ticks);
            ms.SetLength(0);
            writer = new BinaryWriter(ms);
            writer.Write("GE");  // ticker
            writer.Write(500);   // qty
            writer.Write(26.36); // price
            dict["value"] = Value.Get(ms.ToArray());
            list.Add(Value.Get(dict));

            DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19);
            dict["key"] = Value.Get(timestamp3.Ticks);
            ms.SetLength(0);
            writer = new BinaryWriter(ms);
            writer.Write("AAPL");  // ticker
            writer.Write(75);      // qty
            writer.Write(91.85);   // price
            dict["value"] = Value.Get(ms.ToArray());
            list.Add(Value.Get(dict));

            // Verify list size
            int size = list.Size();

            if (size != 3)
            {
                throw new Exception("List size mismatch. Expected 3 Received " + size);
            }

            // Filter on range of timestamps
            DateTime begin = new DateTime(2014, 6, 26);
            DateTime end = new DateTime(2014, 6, 28);
            IList results = list.Range(Value.Get(begin.Ticks), Value.Get(end.Ticks));

            if (results.Count != 2)
            {
                throw new Exception("Query results size mismatch. Expected 2 Received " + results.Count);
            }

            // Verify data.
            ValidateWithSerializedBin(results, 0, timestamp2, "GE", 500, 26.36);
            ValidateWithSerializedBin(results, 1, timestamp3, "AAPL", 75, 91.85);

            console.Info("Data matched.");
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:70,代码来源:LargeList.cs

示例13: TestMapStrings

        /// <summary>
        /// Write/Read HashMap<String,String> directly instead of relying on default serializer.
        /// </summary>
        private void TestMapStrings(AerospikeClient client, Arguments args)
        {
            console.Info("Read/Write HashMap<String,String>");
            Key key = new Key(args.ns, args.set, "mapkey1");
            client.Delete(args.writePolicy, key);

            Dictionary<object, object> map = new Dictionary<object, object>();
            map["key1"] = "string1";
            map["key2"] = "string2";
            map["key3"] = "string3";

            Bin bin = new Bin(args.GetBinName("mapbin1"), map);
            client.Put(args.writePolicy, key, bin);

            Record record = client.Get(args.policy, key, bin.name);
            Dictionary<object, object> receivedMap = (Dictionary<object, object>)record.GetValue(bin.name);

            ValidateSize(3, receivedMap.Count);
            Validate("string1", receivedMap["key1"]);
            Validate("string2", receivedMap["key2"]);
            Validate("string3", receivedMap["key3"]);

            console.Info("Read/Write HashMap<String,String> successful");
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:27,代码来源:ListMap.cs

示例14: RunSimpleExample

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

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

            IDictionary inputMap = new Dictionary<Value, Value>();
            inputMap[Value.Get(1)] = Value.Get(55);
            inputMap[Value.Get(2)] = Value.Get(33);

            // Write values to empty map.
            Record record = client.Operate(args.writePolicy, key, MapOperation.PutItems(MapPolicy.Default, binName, inputMap));

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

            // Pop value from map and also return new size of map.
            record = client.Operate(args.writePolicy, key, MapOperation.RemoveByKey(binName, Value.Get(1), MapReturnType.VALUE), MapOperation.Size(binName));

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

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

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

示例15: RunReplaceOnlyExample

        private void RunReplaceOnlyExample(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "replaceonlykey");
            Bin bin = new Bin("bin", "value");

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

            console.Info("Replace record requiring that it exists: namespace={0} set={1} key={2}",
                key.ns, key.setName, key.userKey);

            try
            {
                WritePolicy policy = new WritePolicy();
                policy.recordExistsAction = RecordExistsAction.REPLACE_ONLY;
                client.Put(policy, key, bin);

                console.Error("Failure. This command should have resulted in an error.");
            }
            catch (AerospikeException ae)
            {
                if (ae.Result == ResultCode.KEY_NOT_FOUND_ERROR)
                {
                    console.Info("Success. Key not found error returned as expected.");
                }
                else
                {
                    throw ae;
                }
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:31,代码来源:Replace.cs


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