79425185

Date: 2025-02-09 15:56:04
Score: 0.5
Natty:
Report link

You don't need to override MappingAerospikeConverter bean, it is enough to use customConverters() method if there is custom conversion logic involved.

You can use configuration properties directly with less boilerplate code.

No need to create AerospikeClient bean, it is created by Spring Data Aerospike. You set ClientPolicy through getClientPolicy() method in your configuration class.

This is what the configuration you posted can look like:

@Configuration
@EnableAerospikeRepositories(basePackageClasses = {CacheableFileEntityRepository.class})
public class AerospikeConfig extends AbstractAerospikeDataConfiguration {


@Override
protected ClientPolicy getClientPolicy() {
    ClientPolicy clientPolicy = super.getClientPolicy(); // applying default values first
    clientPolicy.readPolicyDefault.replica = Replica.MASTER;
    clientPolicy.readPolicyDefault.readModeAP = ReadModeAP.ONE;
    clientPolicy.writePolicyDefault.commitLevel = CommitLevel.COMMIT_ALL;
    clientPolicy.readPolicyDefault.socketTimeout = readTimeout;
    clientPolicy.readPolicyDefault.totalTimeout = totalTimeout;
    clientPolicy.writePolicyDefault.socketTimeout = writeTimeout;
    clientPolicy.writePolicyDefault.totalTimeout = totalTimeout;
    clientPolicy.maxSocketIdle=maxSocketIdle;
    clientPolicy.timeout=connectionTimeout;
    return clientPolicy;
}

@Override
protected List<Object> customConverters() {
    // return List of converters instances here if needed
}

@Bean
public AerospikeCacheManager cacheManager(AerospikeClient aerospikeClient) {
     AerospikeCacheConfiguration defaultConfiguration = new AerospikeCacheConfiguration("tax_registration");
     return new AerospikeCacheManager(aerospikeClient, mappingAerospikeConverter, defaultConfiguration);
     }
}

Can you provide a link to a sample project on GitHub maybe? I was able to run a sample demo with both Redis 3.4.2 and Aerospike 5.0.0.

Reasons:
  • Whitelisted phrase (-1.5): You can use
  • RegEx Blacklisted phrase (2.5): Can you provide
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: nrp