本文整理汇总了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);
}
示例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);
}
}