com.aerospike.client.policy.WritePolicy.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.aerospike.client.policy.WritePolicy.<init>()方法的一些代码示例,展示了WritePolicy.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WritePolicy.<init>()方法的具体详情如下:
包路径:com.aerospike.client.policy.WritePolicy
类名称:WritePolicy
方法名:<init>

WritePolicy.<init>介绍

[英]Default constructor.
[中]默认构造函数。

代码示例

代码示例来源:origin: aerospike/aerospike-client-java

public RWTask(Arguments args, CounterStore counters, long keyStart, long keyCount) {
  this.args = args;
  this.counters = counters;
  this.keyStart = keyStart;
  this.keyCount = keyCount;
  this.valid = true;
  
  writePolicyGeneration = new WritePolicy(args.writePolicy);
  writePolicyGeneration.generationPolicy = GenerationPolicy.EXPECT_GEN_EQUAL;
  writePolicyGeneration.generation = 0;		
}

代码示例来源:origin: spring-projects/spring-data-aerospike

public AerospikeCache(String namespace, String set, AerospikeClient client,
    long expiration){
  this.client = client;
  this.namespace = namespace;
  this.set = set;
  this.createOnly = new WritePolicy(client.writePolicyDefault);
  this.createOnly.recordExistsAction = RecordExistsAction.CREATE_ONLY;
}

代码示例来源:origin: spring-projects/spring-data-aerospike

/**
 * Creates a new {@link WritePolicyFactoryBean}.
 */
public WritePolicyFactoryBean() {
  this.policy = new WritePolicy();
}

代码示例来源:origin: spring-projects/spring-data-aerospike

/**
 * Creates a new {@link AerospikeKeyValueAdapter} using the given {@link AerospikeClient} and
 * {@link AerospikeConverter}.
 * 
 * @param client must not be {@literal null}.
 * @param converter must not be {@literal null}.
 */
public AerospikeKeyValueAdapter(AerospikeClient client, AerospikeConverter converter, String namespace) {
  this.client = client;
  this.converter = converter;
  this.namespace = namespace;
  this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
  this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
  this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
  this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
}

代码示例来源:origin: spring-projects/spring-data-aerospike

public static WritePolicyBuilder builder(WritePolicy policy) {
  Assert.notNull(policy, "Policy must not be null!");
  return new WritePolicyBuilder(new WritePolicy(policy));
}

代码示例来源:origin: apache/gora

public AerospikeMapping() {
 writePolicy = new WritePolicy();
 readPolicy = new Policy();
 binMapping = new HashMap<>();
}

代码示例来源:origin: com.spikeify/core

private WritePolicy getPolicy(){
  WritePolicy writePolicy = overridePolicy != null ? overridePolicy : new WritePolicy(asynClient.getWritePolicyDefault());
  // must be set in order for later queries to return record keys
  writePolicy.sendKey = true;
  return writePolicy;
}

代码示例来源:origin: com.spikeify/core

private WritePolicy getPolicy() {
  WritePolicy writePolicy = overridePolicy != null ? overridePolicy : new WritePolicy(asynClient.getWritePolicyDefault());
  // must be set in order for later queries to return record keys
  writePolicy.sendKey = true;
  writePolicy.recordExistsAction = create ? RecordExistsAction.CREATE_ONLY : forceReplace ? RecordExistsAction.REPLACE : RecordExistsAction.UPDATE;
  return writePolicy;
}

代码示例来源:origin: com.spikeify/core

private WritePolicy getPolicy() {
  WritePolicy writePolicy = overridePolicy != null ? overridePolicy : new WritePolicy(asynClient.getWritePolicyDefault());
  // must be set in order for later queries to return record keys
  writePolicy.sendKey = true;
  if (expiry != null) {
    writePolicy.expiration = expiry.intValue();
  }
  return writePolicy;
}

代码示例来源:origin: org.apache.gora/gora-aerospike

public AerospikeMapping() {
 writePolicy = new WritePolicy();
 readPolicy = new Policy();
 binMapping = new HashMap<>();
}

代码示例来源:origin: com.spikeify/core

private WritePolicy getPolicy() {
  WritePolicy writePolicy = overridePolicy != null ? overridePolicy : new WritePolicy(asynClient.getWritePolicyDefault());
  writePolicy.recordExistsAction = create ? RecordExistsAction.CREATE_ONLY : forceReplace ? RecordExistsAction.REPLACE : RecordExistsAction.UPDATE;
  // must be set so that user key can be retrieved in queries
  writePolicy.sendKey = true;
  return writePolicy;
}

代码示例来源:origin: com.spikeify/core

private WritePolicy getPolicy() {
  return overridePolicy != null ? overridePolicy : new WritePolicy(asynClient.getWritePolicyDefault());
}

代码示例来源:origin: spring-projects/spring-data-aerospike

public WritePolicy build() {
  validate();
  return new WritePolicy(policy);
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Sets the AerospikeClient
 *
 * @param client An instance of AerospikeClient
 */
public void setClient(AerospikeClient client) {
  this.client = client;
  this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
  this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
  this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
  this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
  this.queryPolicy = client.queryPolicyDefault;
  refreshCluster();
  registerUDF();
}

代码示例来源:origin: spring-projects/spring-data-aerospike

@Override
public Object delete(Serializable id, Serializable keyspace) {
  Key key = new Key(namespace, keyspace.toString(), id.toString());
  Object object = get(id, keyspace);
  if (object != null) {
    WritePolicy wp = new WritePolicy();
    wp.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
    client.delete(wp, key);
  }
  return object;
}

代码示例来源:origin: spring-projects/spring-data-aerospike

private Record getAndTouch(Key key, int expiration) {
  WritePolicy writePolicy = new WritePolicy(client.writePolicyDefault);
  writePolicy.expiration = expiration;
  return this.client.operate(writePolicy, key, Operation.touch(), Operation.get());
}

代码示例来源:origin: benmfaul/XRTB

/**
 * Set a key value as string with an expiration (No expiration set on cache2k, it is already set 
 * @param skey String. The key name.
 * @param value String. The value.
 * @throws Exception on aerorpike or cache errors.
 */
public void set(String set, String skey, Object value) throws Exception   {
  WritePolicy policy = new WritePolicy();
  Key key = new Key("test", set, skey);
  Bin bin1 = new Bin("value", value);
  ae.getClient().put(null, key, bin1);
}

代码示例来源:origin: aerospike/aerospike-client-java

private void writeRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  String binName,
  int size
) throws Exception {
  console.info("Write " + size + " records with store user key option.");
  WritePolicy policy = new WritePolicy();
  policy.sendKey = true;
  for (int i = 1; i <= size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    Bin bin = new Bin(binName, i);	
    client.put(policy, key, bin);
  }
}

代码示例来源:origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
public <T> T add(T objectToAddTo, String binName, long value) {
  Assert.notNull(objectToAddTo, "Object to add to must not be null!");
  Assert.notNull(binName, "Bin name must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToAddTo, data);
    WritePolicy writePolicy = new WritePolicy(this.client.writePolicyDefault);
    writePolicy.expiration = data.getExpiration();
    Record record = this.client.operate(writePolicy, data.getKey(),
        Operation.add(new Bin(binName, value)), Operation.get());
    return mapToEntity(data.getKey(), (Class<T>) objectToAddTo.getClass(), record);
  } catch (AerospikeException e) {
    DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e);
    throw translatedException == null ? e : translatedException;
  }
}

代码示例来源:origin: benmfaul/XRTB

/**
 * Do a mhset with expire (No op on cache2k, expiry already set globally
 * @param id String. The key name.
 * @param m Map. The value to set.
 * @param expire int. The number of seconds before expiry.
 * @throws Exception on Cache2k or aerospike errors.
 */
public void hmset(String id, Map m, int expire) throws Exception  {
  if (ae == null) {
    cache.put(id, m);
    return;
  }
  WritePolicy policy = new WritePolicy();
  policy.expiration = expire;
  Key key = new Key("test", "cache", id);
  Bin bin1 = new Bin("value", m);
  ae.getClient().put(policy, key, bin1);
}

相关文章

WritePolicy类方法