/// <summary>
        /// Read record header data in one batch.
        /// </summary>
        private void BatchReadHeaders(AerospikeClient client, Arguments args, string keyPrefix, int size)
        {
            // Batch gets into one call.
            Key[] keys = new Key[size];
            for (int i = 0; i < size; i++)
            {
                keys[i] = new Key(args.ns, args.set, keyPrefix + (i + 1));
            }

            Record[] records = client.GetHeader(null, keys);

            for (int i = 0; i < records.Length; i++)
            {
                Key       key        = keys[i];
                Record    record     = records[i];
                Log.Level level      = Log.Level.ERROR;
                int       generation = 0;
                int       expiration = 0;

                if (record != null && (record.generation > 0 || record.expiration > 0))
                {
                    level      = Log.Level.INFO;
                    generation = record.generation;
                    expiration = record.expiration;
                }
                console.Write(level, "Record: namespace={0} set={1} key={2} generation={3} expiration={4}",
                              key.ns, key.setName, key.userKey, generation, expiration);
            }

            if (records.Length != size)
            {
                console.Error("Record size mismatch. Expected %d. Received %d.", size, records.Length);
            }
        }
Beispiel #2
0
        public static void BatchReadHeaders(AerospikeClient client)
        {
            Key[] keys = new Key[size];
            for (int i = 0; i < size; i++)
            {
                keys[i] = new Key("test", "Write", keyPrefix + (i + 1));
            }

            Record[] records = client.GetHeader(null, keys);
            Console.WriteLine(records.Length);

            for (int i = 0; i < records.Length; i++)
            {
                Key    key    = keys[i];
                Record record = records[i];

                //Varken üstüne bir daha yazarsa bu generation 1 artıyor
                //Console.WriteLine(record.generation);

                /*-2: Do not change ttl when record is updated. Supported by Aerospike server versions >= 3.10.1.
                 * -1: Never expire. Supported by Aerospike server versions >= 3.1.4.
                 * 0: Default to namespace configuration variable "default-ttl" on the server.
                 * > 0: Actual ttl in seconds.
                 * Default: 0
                 */
                Console.WriteLine(record.expiration);

                // yaşı : Convert record expiration(seconds from Jan 01 2010 00:00:00 GMT) to
                Console.WriteLine(record.TimeToLive);
            }
        }
        /// <summary>
        /// Read record header data.
        /// </summary>
        private void RunGetHeaderTest(AerospikeClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "putgetkey");

            console.Info("Get record header: namespace={0} set={1} key={2}", key.ns, key.setName, key.userKey);
            Record record = client.GetHeader(args.policy, key);

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

            // Generation should be greater than zero.  Make sure it's populated.
            if (record.generation == 0)
            {
                throw new Exception(string.Format("Invalid record header: generation={0:D} expiration={1:D}",
                                                  record.generation, record.expiration));
            }
            console.Info("Received: generation={0} expiration={1}", record.generation, record.expiration);
        }