本文整理了Java中com.aerospike.client.policy.WritePolicy
类的一些代码示例,展示了WritePolicy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WritePolicy
类的具体详情如下:
包路径:com.aerospike.client.policy.WritePolicy
类名称:WritePolicy
[英]Container object for policy attributes used in write operations. This object is passed into methods where database writes can occur.
[中]写入操作中使用的策略属性的容器对象。该对象被传递到可以进行数据库写入的方法中。
代码示例来源: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: aerospike/aerospike-client-java
private Map<String, Long> update(KeyRecordIterator results, List<Bin> bins) {
long readCount = 0;
long updateCount = 0;
while (results.hasNext()) {
KeyRecord keyRecord = results.next();
readCount++;
WritePolicy up = new WritePolicy(updatePolicy);
up.generation = keyRecord.record.generation;
try {
client.put(up, keyRecord.key, bins.toArray(new Bin[0]));
updateCount++;
} catch (AerospikeException e) {
System.out.println(keyRecord.key);
}
}
Map<String, Long> map = new HashMap<String, Long>();
map.put("read", readCount);
map.put("write", updateCount);
return map;
}
代码示例来源:origin: com.aerospike/aerospike-client
/**
* Asynchronous default constructor. Do not use directly.
*/
protected AerospikeClient(ClientPolicy policy) {
if (policy != null) {
this.readPolicyDefault = policy.readPolicyDefault;
this.writePolicyDefault = policy.writePolicyDefault;
this.scanPolicyDefault = policy.scanPolicyDefault;
this.queryPolicyDefault = policy.queryPolicyDefault;
this.batchPolicyDefault = policy.batchPolicyDefault;
this.infoPolicyDefault = policy.infoPolicyDefault;
this.operatePolicyReadDefault = new WritePolicy(this.readPolicyDefault);
}
else {
this.readPolicyDefault = new Policy();
this.writePolicyDefault = new WritePolicy();
this.scanPolicyDefault = new ScanPolicy();
this.queryPolicyDefault = new QueryPolicy();
this.batchPolicyDefault = new BatchPolicy();
this.infoPolicyDefault = new InfoPolicy();
this.operatePolicyReadDefault = new WritePolicy(this.readPolicyDefault);
}
}
代码示例来源:origin: aerospike/aerospike-client-java
/**
* Asynchronous default constructor. Do not use directly.
*/
protected AerospikeClient(ClientPolicy policy) {
if (policy != null) {
this.readPolicyDefault = policy.readPolicyDefault;
this.writePolicyDefault = policy.writePolicyDefault;
this.scanPolicyDefault = policy.scanPolicyDefault;
this.queryPolicyDefault = policy.queryPolicyDefault;
this.batchPolicyDefault = policy.batchPolicyDefault;
this.infoPolicyDefault = policy.infoPolicyDefault;
this.operatePolicyReadDefault = new WritePolicy(this.readPolicyDefault);
}
else {
this.readPolicyDefault = new Policy();
this.writePolicyDefault = new WritePolicy();
this.scanPolicyDefault = new ScanPolicy();
this.queryPolicyDefault = new QueryPolicy();
this.batchPolicyDefault = new BatchPolicy();
this.infoPolicyDefault = new InfoPolicy();
this.operatePolicyReadDefault = new WritePolicy(this.readPolicyDefault);
}
}
代码示例来源:origin: aerospike/aerospike-loader
WritePolicy writePolicy = new WritePolicy();
writePolicy.recordExistsAction = RecordExistsAction.valueOf(writeAction.toUpperCase());
writePolicy.timeout = timeout_int;
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!