forked from spring-attic/spring-data-aerospike
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into FMWK-265-prepare-rele…
…ase-4.6.0 # Conflicts: # src/main/asciidoc/reference/aerospike.adoc # src/main/asciidoc/reference/getting-started.adoc
- Loading branch information
Showing
35 changed files
with
1,174 additions
and
1,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,177 +0,0 @@ | ||
[[aerospike.functionality]] | ||
= Aerospike Functionality | ||
|
||
Aerospike supports a wide range of features summarized below: | ||
|
||
* Feature Rich Object Mapping integrated with Spring's Conversion Service | ||
* Automatic implementation of Repository interfaces including support for custom finder methods | ||
* AerospikeTemplate helper class for performing common Aerospike operations | ||
* Exceptions translation into Spring's portable Data Access Exception hierarchy | ||
* Annotation-based mapping metadata but extensible to support other metadata formats | ||
|
||
[[aerospike-getting-started]] | ||
== Getting Started | ||
|
||
Spring Data Aerospike uses Java Client, Aerospike’s Java client enables you to build applications in Java that store and retrieve data from an Aerospike cluster. It contains both synchronous and asynchronous calls to the database. | ||
|
||
The Java Client runs on any platform with Java 1.8 version and above. | ||
|
||
First, you need to set up a running Aerospike server. | ||
|
||
To create a Spring project in STS go to File -> New -> Spring Template Project -> Simple Spring Utility Project -> press Yes when prompted. Then enter a project and a package name such as org.spring.aerospike.example. | ||
|
||
Then add the following to `pom.xml` dependencies section. | ||
|
||
[source,xml] | ||
---- | ||
<dependencies> | ||
<!-- other dependency elements omitted --> | ||
<dependency> | ||
<groupId>com.aerospike</groupId> | ||
<artifactId>spring-data-aerospike</artifactId> | ||
<version>4.6.0</version> | ||
</dependency> | ||
</dependencies> | ||
---- | ||
|
||
You can either set up Spring Boot or Spring application. Basic setup of Spring Boot application is described under the following link: https://projects.spring.io/spring-boot. | ||
|
||
.Spring Boot compatibility | ||
[width="100%",cols="<24%,<14%,<18%,<26%,<18%",options="header",] | ||
|=== | ||
|Spring Data Aerospike |Spring Boot |Aerospike Client |Aerospike Reactor Client |Aerospike Server | ||
|4.6.x |3.2.x |7.2.x |7.1.x |5.2.x.x + | ||
|
||
|4.5.x |3.1.x |7.1.x |7.0.x |5.2.x.x + | ||
|
||
|4.4.x |3.1.x |7.0.x |7.0.x |5.2.x.x + | ||
|
||
|4.3.x |3.1.x |6.1.x |6.1.x |5.2.x.x + | ||
|
||
|4.2.x |3.0.x |6.1.x |6.1.x |5.2.x.x + | ||
|
||
|4.1.x |3.0.x |6.1.x |6.1.x |5.2.x.x + | ||
|
||
|3.5.x |2.7.x |6.1.x |6.1.x |5.2.x.x + | ||
|
||
|3.4.x |2.6.x |5.1.x |5.1.x |5.2.x.x + | ||
|
||
|3.3.x |2.5.x |5.1.x |5.1.x |5.2.x.x + | ||
|
||
|3.2.x |2.5.x |5.1.x |5.0.x |5.2.x.x + | ||
|
||
|3.0.x, 3.1.x |2.5.x |5.1.x |5.0.x | | ||
|
||
|2.5.x |2.5.x |4.4.x |4.4.x | | ||
|
||
|2.4.2.RELEASE |2.3.x |4.4.x |4.4.x | | ||
|
||
|2.3.5.RELEASE |2.2.x |4.4.x |4.4.x | | ||
|
||
|2.1.1.RELEASE |2.1.x, 2.0.x |4.4.x |3.2.x | | ||
|
||
|1.2.1.RELEASE |1.5.x |4.1.x | | | ||
|=== | ||
|
||
In case you do not want to use Spring Boot, the best way to manage Spring dependencies is to declare `spring-framework-bom` of the needed version in the `dependencyManagement` section of your `pom.xml`: | ||
|
||
[source,xml] | ||
---- | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-framework-bom</artifactId> | ||
<version>${place Spring version here}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
---- | ||
|
||
Create a simple Person class to persist. | ||
|
||
[source,java] | ||
---- | ||
package org.springframework.data.aerospike.example; | ||
public class Person { | ||
public final String id; | ||
public final String name; | ||
public final int age; | ||
public Person(String id, String name, int age) { | ||
this.id = id; | ||
this.name = name; | ||
this.age = age; | ||
} | ||
@Override | ||
public String toString() { | ||
return "Person [id=" + id + ", name=" + name + ", age=" + age + "]"; | ||
} | ||
} | ||
---- | ||
|
||
In the simplest case, your repository will extend the AerospikeRepository<T, String>, where T is the entity that you want to expose. | ||
|
||
[source,java] | ||
---- | ||
package org.springframework.data.aerospike.example.repo; | ||
import org.springframework.data.aerospike.repository.AerospikeRepository; | ||
public interface PersonRepository extends AerospikeRepository<Person, String> { | ||
} | ||
---- | ||
Please note that this is just an interface and not an actual class. In the background, when your context gets initialized, actual implementations for your repository descriptions get created and you can access them through regular beans. | ||
This means you will save lots of boilerplate code while still exposing full CRUD semantics to your service layer and application. | ||
|
||
To setup configuration for Aerospike you will need to subclass `AbstractAerospikeDataConfiguration`: | ||
|
||
[source,java] | ||
---- | ||
package org.springframework.data.aerospike.example.config; | ||
import com.aerospike.client.Host; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.aerospike.repository.config.EnableAerospikeRepositories; | ||
import org.springframework.data.aerospike.example.repo.PersonRepository; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
@Configuration | ||
@EnableAerospikeRepositories(basePackageClasses = PersonRepository.class) | ||
public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { | ||
@Override | ||
protected Collection<Host> getHosts() { | ||
return Collections.singleton(new Host("localhost", 3000)); | ||
} | ||
@Override | ||
protected String nameSpace() { | ||
return "SAMPLE"; | ||
} | ||
} | ||
---- | ||
|
||
Now you are ready to inject and use `PersonRepository` in your application. | ||
|
||
[[aerospike.auditing]] | ||
== General auditing configuration | ||
|
||
Auditing support is not available in the current version. | ||
|
||
[[aerospike-template-intro]] | ||
== Introduction to AerospikeTemplate | ||
|
||
The template provides lower-level access to the database and also serves as the foundation for repositories. | ||
For more information see xref:#aerospike.template[AerospikeTemplate] for more information. | ||
|
||
Oops, something went wrong.