Ejemplo n.º 1
0
        protected void printRecord(Key key, Record record)
        {
            Console.WriteLine("Key");
            if (key == null)
            {
                Console.WriteLine("\tkey == null");
            }
            else
            {
                Console.WriteLine(String.Format("\tNamespace: {0}", key.ns));
                Console.WriteLine(String.Format("\t      Set: {0}", key.setName));
                Console.WriteLine(String.Format("\t      Key: {0}", key.userKey));
                Console.WriteLine(String.Format("\t   Digest: {0}", key.digest.ToString()));
            }
            Console.WriteLine("Record");
            if (record == null)
            {
                Console.WriteLine("\trecord == null");
            }
            else
            {
                Console.WriteLine(String.Format("\tGeneration: {0}", record.generation));
                Console.WriteLine(String.Format("\tExpiration: {0}", record.expiration));
                Console.WriteLine(String.Format("\t       TTL: {0}", record.TimeToLive));
                Console.WriteLine("Bins");

                foreach (KeyValuePair<string, Object> entry in record.bins)
                {
                    Console.WriteLine(String.Format("\t{0} = {1}", entry.Key, entry.Value.ToString()));
                }
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        /// <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));
        }
 public ReadHeaderCommand(Cluster cluster, Policy policy, Key key)
 {
     this.cluster = cluster;
     this.policy = policy;
     this.key = key;
     this.partition = new Partition(key);
 }
Ejemplo n.º 5
0
        public void InsertByKey()
        {
            int i = 0;
            for (int x = 1; x <= TestQueryEngine.RECORD_COUNT; x++)
            {
                String keyString = "selector-test:" + x;

                Bin name = new Bin("name", "name:" + x);
                Bin age = new Bin("age", ages[i]);
                Bin colour = new Bin("color", colours[i]);
                Bin animal = new Bin("animal", animals[i]);
                List<Bin> bins = new List<Bin>() { name, age, colour, animal };

                Key key = new Key(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, keyString);
                this.client.Delete(null, key);

                KeyQualifier kq = new KeyQualifier(Value.Get(keyString));
                Statement stmt = new Statement();
                stmt.Namespace = TestQueryEngine.NAMESPACE;
                stmt.SetName = TestQueryEngine.SET_NAME;

                queryEngine.Insert(stmt, kq, bins);

                Record record = this.client.Get(null, key);
                Assert.NotNull(record);
                i++;
                if (i == 5)
                    i = 0;
            }
        }
Ejemplo n.º 6
0
        private void RunPutGet(AsyncClient client, Arguments args, Key key, Bin bin)
        {
            console.Info("Put: namespace={0} set={1} key={2} value={3}",
                key.ns, key.setName, key.userKey, bin.value);

            client.Put(args.writePolicy, new WriteHandler(this, client, args.writePolicy, key, bin), key, bin);
        }
Ejemplo n.º 7
0
        public void PutGet()
        {
            Key key = new Key(args.ns, args.set, "putgetkey");
            Record record;

            if (args.singleBin)
            {
                Bin bin = new Bin("", "value");

                client.Put(null, key, bin);
                record = client.Get(null, key);
                AssertBinEqual(key, record, bin);
            }
            else {
                Bin bin1 = new Bin("bin1", "value1");
                Bin bin2 = new Bin("bin2", "value2");

                client.Put(null, key, bin1, bin2);
                record = client.Get(null, key);
                AssertBinEqual(key, record, bin1);
                AssertBinEqual(key, record, bin2);
            }

            record = client.GetHeader(null, key);
            AssertRecordFound(key, record);

            // Generation should be greater than zero.  Make sure it's populated.
            if (record.generation == 0)
            {
                Assert.Fail("Invalid record header: generation=" + record.generation + " expiration=" + record.expiration);
            }
        }
        public static void Main(string[] args)
        {
            var client = Connect();
            var policy = new Policy();
            var writePolicy = new WritePolicy();
            var batchPolicy = new BatchPolicy();

            //NOTE: adjust the timeout value depending on your demo machine
            writePolicy.timeout = 1000;
            var key = new Key("test", "myset", "mykey");

            WriteSingleValue(client, writePolicy, key);
            CheckKeyExists(client, policy, key);
            AddSingleValue(client, writePolicy);
            WriteMultipleValues(client, writePolicy, key);
            WriteValueWithTtl(client);

            ReadAllValuesForKey(client, policy, key);
            ReadSomeValuesForKey(client, policy, key);

            DeleteValue(client, writePolicy, key);
            DeleteRecord(client, writePolicy, key);

            AddRecords(client, writePolicy);
            BatchReadRecords(client, batchPolicy);

            MultiOps(client, writePolicy, key);

            client.Close();
        }
Ejemplo n.º 9
0
        public void LargeMap()
        {
            if (!args.ValidateLDT())
            {
                return;
            }
            Key key = new Key(args.ns, args.set, "setkey");
            string binName = args.GetBinName("setbin");

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

            // Initialize Large Map operator.
            LargeMap lmap = client.GetLargeMap(null, key, binName, null);

            // Write values.
            lmap.Put(Value.Get("lmapName1"), Value.Get("lmapValue1"));
            lmap.Put(Value.Get("lmapName2"), Value.Get("lmapValue2"));
            lmap.Put(Value.Get("lmapName3"), Value.Get("lmapValue3"));

            // Remove last value.
            lmap.Remove(Value.Get("lmapName3"));
            Assert.AreEqual(2, lmap.Size());

            IDictionary mapReceived = lmap.Get(Value.Get("lmapName2"));
            string stringReceived = (string)mapReceived["lmapName2"];
            Assert.AreEqual("lmapValue2", stringReceived);
        }
        public static void Prepare(TestContext testContext)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA);
            rtask.Wait();

            Policy policy = new Policy();
            policy.timeout = 0; // Do not timeout on index create.
            IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS);
            task.Wait();

            for (int i = 1; i <= size; i++)
            {
                Key key = new Key(args.ns, args.set, keyPrefix + i);
                Dictionary<string, string> map = new Dictionary<string, string>();

                map[mapKeyPrefix + 1] = mapValuePrefix + i;
                if (i % 2 == 0)
                {
                    map[mapKeyPrefix + 2] = mapValuePrefix + i;
                }
                if (i % 3 == 0)
                {
                    map[mapKeyPrefix + 3] = mapValuePrefix + i;
                }

                Bin bin = new Bin(binName, map);
                client.Put(null, key, bin);
            }
        }
Ejemplo n.º 11
0
        public AsyncBatchExistsArrayExecutor(
			AsyncCluster cluster,
			BatchPolicy policy,
			Key[] keys,
			ExistsArrayListener listener
		)
            : base(cluster, policy, keys)
        {
            this.existsArray = new bool[keys.Length];
            this.listener = listener;

            // Create commands.
            AsyncMultiCommand[] tasks = new AsyncMultiCommand[base.taskSize];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                if (batchNode.node.UseNewBatch(policy))
                {
                    // New batch
                    tasks[count++] = new AsyncBatchExistsArrayCommand(this, cluster, batchNode, policy, keys, existsArray);
                }
                else
                {
                    // Old batch only allows one namespace per call.
                    foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                    {
                        tasks[count++] = new AsyncBatchExistsArrayDirect(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, existsArray);
                    }
                }
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentThreads);
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        public void LargeStack()
        {
            Key key = new Key(args.ns, args.set, "stackkey");
            string binName = args.GetBinName("stackbin");

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

            // Initialize large stack operator.
            LargeStack stack = client.GetLargeStack(null, key, binName, null);

            // Write values.
            stack.Push(Value.Get("stackvalue1"));
            stack.Push(Value.Get("stackvalue2"));
            //stack.push(Value.get("stackvalue3"));

            // Delete last value.
            // Comment out until trim supported on server.
            //stack.trim(1);

            Assert.AreEqual(2, stack.Size());

            IList list = stack.Peek(1);
            string received = (string)list[0];
            Assert.AreEqual("stackvalue2", received);
        }
Ejemplo n.º 14
0
        public void Replace()
        {
            Key key = new Key(args.ns, args.set, "replacekey");
            Bin bin1 = new Bin("bin1", "value1");
            Bin bin2 = new Bin("bin2", "value2");
            Bin bin3 = new Bin("bin3", "value3");

            client.Put(null, key, bin1, bin2);

            WritePolicy policy = new WritePolicy();
            policy.recordExistsAction = RecordExistsAction.REPLACE;
            client.Put(policy, key, bin3);

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

            if (record.GetValue(bin1.name) != null)
            {
                Assert.Fail(bin1.name + " found when it should have been deleted.");
            }

            if (record.GetValue(bin2.name) != null)
            {
                Assert.Fail(bin2.name + " found when it should have been deleted.");
            }
            AssertBinEqual(key, record, bin3);
        }
        public void OperateList1()
        {
            Key key = new Key(args.ns, args.set, "oplkey1");

            client.Delete(null, key);

            // Calling append() multiple times performs poorly because the server makes
            // a copy of the list for each call, but we still need to test it.
            // Using appendItems() should be used instead for best performance.
            Record record = client.Operate(null, key,
                ListOperation.Append(binName, Value.Get(55)),
                ListOperation.Append(binName, Value.Get(77)),
                ListOperation.Pop(binName, -1),
                ListOperation.Size(binName)
                );

            AssertRecordFound(key, record);

            IList list = record.GetList(binName);

            long size = (long)list[0];
            Assert.AreEqual(1, size);

            size = (long)list[1];
            Assert.AreEqual(2, size);

            long val = (long)list[2];
            Assert.AreEqual(77, val);

            size = (long)list[3];
            Assert.AreEqual(1, size);
        }
Ejemplo n.º 16
0
 public static void AssertRecordFound(Key key, Record record)
 {
     if (record == null)
     {
         Assert.Fail("Failed to get: namespace=" + args.ns + " set=" + args.set + " key=" + key.userKey);
     }
 }
        public void OperateMapClear()
        {
            // Test clear.
            if (!args.ValidateMap())
            {
                return;
            }

            Key key = new Key(args.ns, args.set, "opmkey9");
            client.Delete(null, key);

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

            Record record = client.Operate(null, key, MapOperation.PutItems(MapPolicy.Default, binName, inputMap));

            AssertRecordFound(key, record);

            long size = record.GetLong(binName);
            Assert.AreEqual(2, size);

            record = client.Operate(null, key,
                MapOperation.Clear(binName),
                MapOperation.Size(binName)
                );

            IList results = record.GetList(binName);
            size = (long)results[1];
            Assert.AreEqual(0, size);
        }
Ejemplo n.º 18
0
        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);

                }
            }
        }
Ejemplo n.º 19
0
        public void ListComplex()
        {
            Key key = new Key(args.ns, args.set, "listkey2");
            client.Delete(null, key);

            string geopoint = "{ \"type\": \"Point\", \"coordinates\": [0.00, 0.00] }";

            byte[] blob = new byte[] {3, 52, 125};
            List<object> list = new List<object>();
            list.Add("string1");
            list.Add(2);
            list.Add(blob);
            list.Add(Value.GetAsGeoJSON(geopoint));

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

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

            Assert.AreEqual(4, receivedList.Count);
            Assert.AreEqual("string1", receivedList[0]);
            // Server convert numbers to long, so must expect long.
            Assert.AreEqual(2L, receivedList[1]);
            CollectionAssert.AreEqual(blob, (byte[])receivedList[2]);
            Assert.AreEqual(Value.GetAsGeoJSON(geopoint), (Value)receivedList[3]);
        }
Ejemplo n.º 20
0
        /// <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.");
        }
Ejemplo n.º 21
0
 /// <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);
 }
        public void LargeSet()
        {
            if (!args.ValidateLDT())
            {
                return;
            }
            Key key = new Key(args.ns, args.set, "setkey");
            string binName = args.GetBinName("setbin");

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

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

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

            // Remove last value.
            set.Remove(Value.Get("setvalue3"));
            Assert.AreEqual(2, set.Size());

            string received = (string)set.Get(Value.Get("setvalue2"));
            Assert.AreEqual("setvalue2", received);
        }
Ejemplo n.º 23
0
        public void DistinctBinsLargeList()
        {
            Key key = new Key(args.ns, args.set, "accountId");

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

            // Initialize large list operator.
            LargeList list = client.GetLargeList(null, key, "trades");

            // Write trades
            Dictionary<string, Value> map = new Dictionary<string, Value>();

            DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43);
            map["key"] = Value.Get(timestamp1.Ticks);
            map["ticker"] = Value.Get("IBM");
            map["qty"] = Value.Get(100);
            map["price"] = Value.Get(BitConverter.GetBytes(181.82));
            list.Add(Value.Get(map));

            DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17);
            map["key"] = Value.Get(timestamp2.Ticks);
            map["ticker"] = Value.Get("GE");
            map["qty"] = Value.Get(500);
            map["price"] = Value.Get(BitConverter.GetBytes(26.36));
            list.Add(Value.Get(map));

            DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19);
            map["key"] = Value.Get(timestamp3.Ticks);
            map["ticker"] = Value.Get("AAPL");
            map["qty"] = Value.Get(75);
            map["price"] = Value.Get(BitConverter.GetBytes(91.85));
            list.Add(Value.Get(map));

            // Verify list size
            int size = list.Size();
            Assert.AreEqual(3, 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));
            Assert.IsNotNull(results);
            Assert.AreEqual(2, results.Count);

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

            IList rows = list.Scan();
            foreach (IDictionary row in rows)
            {
                foreach (DictionaryEntry entry in row)
                {
                    //console.Info(entry.Key.ToString());
                    //console.Info(entry.Value.ToString());
                }
            }
        }
 public AsyncReadHeader(AsyncCluster cluster, Policy policy, RecordListener listener, Key key)
     : base(cluster)
 {
     this.policy = policy;
     this.listener = listener;
     this.key = key;
     this.partition = new Partition(key);
 }
Ejemplo n.º 25
0
 private void add()
 {
     // C# Add Example
     Key userKey = new Key("test", "users", "user1234");
     Bin bin1 = new Bin("count", 2);
     Bin bin2 = new Bin("count", 3);
     client.Add(null, userKey, bin2);
 }
Ejemplo n.º 26
0
 public ReadCommand(Cluster cluster, Policy policy, Key key, string[] binNames)
 {
     this.cluster = cluster;
     this.policy = policy;
     this.key = key;
     this.partition = new Partition(key);
     this.binNames = binNames;
 }
 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);
     }
 }
Ejemplo n.º 28
0
 /// <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);
 }
        public void AsyncPutGet()
        {
            Key key = new Key(args.ns, args.set, "putgetkey1");
            Bin bin = new Bin(binName, "value1");

            client.Put(null, new WriteHandler(this, client, key, bin), key, bin);
            WaitTillComplete();
        }
 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("");
 }
Ejemplo n.º 31
0
        private static void AerospikeReadMethod(long userId)
        {
            using (var client = new AC.AerospikeClient(Config.DOCKER_MACHINE_IP, 3000))
            {
                if (!client.Connected)
                {
                    Console.WriteLine("Aerospike ERROR: Connection failed!");
                    return;
                }

                var key = new AC.Key("test", "users", userId);

                var user = client.Get(null, key);
                if (user != null)
                {
                    Console.WriteLine($"Aerospike: ID: {user.GetValue("id")}, Name: {user.GetValue("name")}, Age:{user.GetValue("age")}");
                }
                else
                {
                    Console.WriteLine("Aerospike ERROR: User record not found!");
                }
            }
        }
Ejemplo n.º 32
0
        private static void AerospikeWriteMethod(User user)
        {
            using (var client = new AC.AerospikeClient(Config.DOCKER_MACHINE_IP, 3000))
            {
                if (!client.Connected)
                {
                    Console.WriteLine("Aerospike ERROR: Connection failed!");
                    return;
                }

                var wPolicy = new AC.WritePolicy
                {
                    recordExistsAction = AC.RecordExistsAction.UPDATE
                };

                var key     = new AC.Key("test", "users", user.Id);
                var binId   = new AC.Bin("id", user.Id);
                var binName = new AC.Bin("name", user.Name);
                var binAge  = new AC.Bin("age", user.Age);

                client.Put(wPolicy, key, binId, binName, binAge);
            }
        }
 public void OnSuccess(Key key, bool existed)
 {
     SetResult(existed);
 }
Ejemplo n.º 34
0
 public ReadCommand(Key key)
 {
     this.policy   = null;
     this.key      = key;
     this.binNames = null;
 }
Ejemplo n.º 35
0
 public ReadCommand(Policy policy, Key key, string[] binNames)
 {
     this.policy   = policy;
     this.key      = key;
     this.binNames = binNames;
 }
Ejemplo n.º 36
0
		public AsyncExecute(AsyncCluster cluster, WritePolicy writePolicy, ExecuteListener listener, Key key, string packageName, string functionName, Value[] args)
			: base(cluster, writePolicy, null, key, null, false)
		{
			this.writePolicy = writePolicy;
			this.executeListener = listener;
			this.packageName = packageName;
			this.functionName = functionName;
			this.args = args;
		}
Ejemplo n.º 37
0
 protected internal abstract void ParseRow(Key key);
Ejemplo n.º 38
0
 public ExistsCommand(Policy policy, Key key)
 {
     this.policy = policy;
     this.key    = key;
 }