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


C# AerospikeClient.GetHeader方法代码示例

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


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

示例1: RunGetHeaderTest

        /// <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);
        }
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:24,代码来源:PutGet.cs

示例2: BatchReadHeaders

        /// <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);
            }
        }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:37,代码来源:Batch.cs


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