We now enable storing domain object as a flat Redis 'HASH' and maintain additional 'SET' structures to enable finder operations on simple properties.
@RedisHash("persons");
class Person {
@id String id;
@Indexed String firstname;
String lastname;
Map<String, String> attributes;
City city;
@Reference Person mother;
}
The above is stored in the HASH with key 'persons:1' as
_class = org.example.Person
id = 1
firstname = rand
lastname = al’thor
attributes.[eye-color] = grey
attributes.[hair-color] = red
city.name = emond's field
city.region = two rivers
mother = persons:2
Complex types are flattened out to their full property path for each of the values provided. If the properties actual value type does not match the declared one the '_class' type hint is added to the entry.
city._class = CityInAndor.class
city.name = emond's field
city.region = two rivers
city.country = andor
Map and Collection like structures are stored with their key/index values as part of the property path. If the map/collection value type does not match the actutal objects one the '_class' type hint is added to the entry.
list.[0]._class = DomainType.class
list.[0].property1 = ...
map.[key-1]._class = DomainType.class
map.[key-1].property1 = ...
Properties marked with '@Reference' are stored as semantic references by just storing the key to the referenced object 'HASH' instead of embedding its values.
mother = persons:2
Please note that referenced objects are not transitively updated/saved and that lazy loading of references will be part of future development.
A 'save' operation therefore executes the following:
# flatten domain type and add as hash
HMSET persons:1 id 1 firstname rand …
# add the newly inserted entry to the list of all entries of that type
SADD persons 1
# index the firstname for finder lookup
SADD persons.firstname:rand 1
Simple finder operation like 'findByFirstname' use 'SINTER' to find matching
SINTER persons.firstname:rand
HGETALL persons:1
Besides resolving an index via the '@Index' annotation we also allow to add custom configuration via the 'indexConfiguration' attribute of '@EnableRedisRepositories'.
@Configuration
@EnableRedisRepositories(indexConfiguration = CustomIndexConfiguration.class)
class Config { }
static class CustomIndexConfiguration extends IndexConfiguration {
@Override
protected Iterable<RedisIndexDefinition> initialConfiguration() {
return Arrays.asList(
new SimpleIndexDefinition("persons", "lastname"),
);
}
}
The '@TimeToLive' annotation allows to define a property or method providing an expiration time when storing the key in redis.
@RedisHash
class Person {
@Id String id;
@TimeToLive Long ttl;
}
Original Pull Request: #156
260 lines
6.1 KiB
XML
260 lines
6.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
<groupId>org.springframework.data</groupId>
|
|
<artifactId>spring-data-redis</artifactId>
|
|
<version>1.7.0.BUILD-SNAPSHOT</version>
|
|
|
|
<name>Spring Data Redis</name>
|
|
|
|
<parent>
|
|
<groupId>org.springframework.data.build</groupId>
|
|
<artifactId>spring-data-parent</artifactId>
|
|
<version>1.8.0.BUILD-SNAPSHOT</version>
|
|
</parent>
|
|
|
|
<properties>
|
|
<dist.key>DATAREDIS</dist.key>
|
|
<springdata.keyvalue>1.1.0.BUILD-SNAPSHOT</springdata.keyvalue>
|
|
<jta>1.1</jta>
|
|
<beanutils>1.9.2</beanutils>
|
|
<xstream>1.4.8</xstream>
|
|
<pool>2.2</pool>
|
|
<lettuce>3.4.1.Final</lettuce>
|
|
<jedis>2.8.0</jedis>
|
|
<srp>0.7</srp>
|
|
<jredis>06052013</jredis>
|
|
<multithreadedtc>1.01</multithreadedtc>
|
|
</properties>
|
|
|
|
<dependencyManagement>
|
|
<dependencies>
|
|
|
|
<dependency>
|
|
<groupId>org.apache.commons</groupId>
|
|
<artifactId>commons-pool2</artifactId>
|
|
<version>${pool}</version>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.google.guava</groupId>
|
|
<artifactId>guava</artifactId>
|
|
<version>${guava}</version>
|
|
</dependency>
|
|
|
|
</dependencies>
|
|
</dependencyManagement>
|
|
|
|
<dependencies>
|
|
|
|
<!-- Spring -->
|
|
|
|
<dependency>
|
|
<groupId>org.springframework.data</groupId>
|
|
<artifactId>spring-data-keyvalue</artifactId>
|
|
<version>${springdata.keyvalue}</version>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-tx</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-oxm</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-aop</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-context-support</artifactId>
|
|
</dependency>
|
|
|
|
<!-- REDIS Drivers -->
|
|
|
|
<dependency>
|
|
<groupId>redis.clients</groupId>
|
|
<artifactId>jedis</artifactId>
|
|
<version>${jedis}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.jredis</groupId>
|
|
<artifactId>jredis-core-api</artifactId>
|
|
<version>${jredis}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.jredis</groupId>
|
|
<artifactId>jredis-core-ri</artifactId>
|
|
<version>${jredis}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.github.spullara.redis</groupId>
|
|
<artifactId>client</artifactId>
|
|
<version>${srp}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>biz.paluch.redis</groupId>
|
|
<artifactId>lettuce</artifactId>
|
|
<version>${lettuce}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<!--Mapper -->
|
|
|
|
<dependency>
|
|
<groupId>org.codehaus.jackson</groupId>
|
|
<artifactId>jackson-mapper-asl</artifactId>
|
|
<version>1.8.8</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
<artifactId>jackson-core</artifactId>
|
|
<version>${jackson}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
<artifactId>jackson-databind</artifactId>
|
|
<version>${jackson}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>commons-beanutils</groupId>
|
|
<artifactId>commons-beanutils</artifactId>
|
|
<version>${beanutils}</version>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<!-- Pool -->
|
|
|
|
<dependency>
|
|
<groupId>org.apache.commons</groupId>
|
|
<artifactId>commons-pool2</artifactId>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
|
|
<!-- Test -->
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-jdbc</artifactId>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>javax.transaction</groupId>
|
|
<artifactId>jta</artifactId>
|
|
<version>${jta}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>javax.annotation</groupId>
|
|
<artifactId>jsr250-api</artifactId>
|
|
<version>1.0</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.thoughtworks.xstream</groupId>
|
|
<artifactId>xstream</artifactId>
|
|
<version>${xstream}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>edu.umd.cs.mtc</groupId>
|
|
<artifactId>multithreadedtc</artifactId>
|
|
<version>${multithreadedtc}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
</dependencies>
|
|
|
|
<build>
|
|
<plugins>
|
|
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-surefire-plugin</artifactId>
|
|
<configuration>
|
|
<includes>
|
|
<include>**/*Tests.java</include>
|
|
<include>**/*Test.java</include>
|
|
</includes>
|
|
<reuseForks>false</reuseForks>
|
|
<systemProperties>
|
|
<gemfire.disableShutdownHook>true</gemfire.disableShutdownHook>
|
|
<javax.net.ssl.keyStore>${basedir}/src/test/resources/trusted.keystore</javax.net.ssl.keyStore>
|
|
</systemProperties>
|
|
</configuration>
|
|
</plugin>
|
|
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-assembly-plugin</artifactId>
|
|
</plugin>
|
|
|
|
<plugin>
|
|
<groupId>org.codehaus.mojo</groupId>
|
|
<artifactId>wagon-maven-plugin</artifactId>
|
|
</plugin>
|
|
|
|
<plugin>
|
|
<groupId>org.asciidoctor</groupId>
|
|
<artifactId>asciidoctor-maven-plugin</artifactId>
|
|
</plugin>
|
|
|
|
</plugins>
|
|
</build>
|
|
|
|
<profiles>
|
|
<profile>
|
|
<id>release</id>
|
|
<build>
|
|
<plugins>
|
|
|
|
<plugin>
|
|
<groupId>org.jfrog.buildinfo</groupId>
|
|
<artifactId>artifactory-maven-plugin</artifactId>
|
|
<inherited>false</inherited>
|
|
</plugin>
|
|
|
|
</plugins>
|
|
</build>
|
|
</profile>
|
|
</profiles>
|
|
|
|
<repositories>
|
|
<repository>
|
|
<id>spring-libs-snapshot</id>
|
|
<url>https://repo.spring.io/libs-snapshot</url>
|
|
</repository>
|
|
</repositories>
|
|
|
|
<pluginRepositories>
|
|
<pluginRepository>
|
|
<id>spring-plugins-release</id>
|
|
<url>https://repo.spring.io/plugins-release</url>
|
|
</pluginRepository>
|
|
</pluginRepositories>
|
|
</project>
|