Commit Graph

358 Commits

Author SHA1 Message Date
Christoph Strobl
f5ecd3a9b1 DATAREDIS-501 - Use application context ClassLoader as default for JdkSerializationRedisSerializer in RedisTemplate.
We now pick up the ClassLoader from the ApplicationContext and use the latter as default in RedisTemplate for initializing the JdkSerializationRedisSerializer. We only do this in case the default serializer has not been set explicitly.

Original pull request: #192.
2016-04-26 15:12:11 +02:00
Christoph Strobl
652b1b8354 DATAREDIS-489 - Add type hints for Object types.
We now store the type hint for simple types when the declaring bean property does not match the actual value type.
2016-04-15 11:09:36 +02:00
Christoph Strobl
14e44880c7 DATAREDIS-492 - Polishing.
Added some more tests and fix read operation.

Original Pull Request: #189
2016-04-15 11:09:13 +02:00
Greg Turnquist
2492fbe332 DATAREDIS-492 - Handle serializing arrays and collections.
Original Pull Request: #189
2016-04-15 11:09:13 +02:00
Christoph Strobl
deec98efc6 DATAREDIS-498 - Favor Collections.sort over List.sort which requires Java 8. 2016-04-15 11:08:33 +02:00
Mark Paluch
bef4fbe831 DATAREDIS-444 - Polishing.
Add author name. Update license header. Reformat code. Add JavaDoc to hash operations.

Original pull request: #184.
2016-03-29 10:30:55 +02:00
Ninad Divadkar
5f9d005cb3 DATAREDIS-444 - Return result of delete in DefaultHashOperation.
Delete in DefaultHashOperation returns now the result of the HDEL command.

Original pull request: #184.
CLA: 169220160326121428 (Ninad Divadkar)
2016-03-29 09:25:57 +02:00
Christoph Strobl
1b3fe81b61 DATAREDIS-482 - Provide meaningful exception messages in MappingRedisConverter.
Original pull request: #183.
2016-03-24 14:49:58 +01:00
Mark Paluch
b3243ff328 DATAREDIS-480 - Polishing.
Add missing author tag. Minor reformatting. Explicitly set default SSL options and add test to verify default SSL options. Enhance JavaDoc.

Original pull request: #180.
2016-03-22 11:06:10 +01:00
Balazs Nemeth
8edfb2b94e DATAREDIS-480 - Add support for all lettuce SSL options.
LettuceConnectionFactory now supports verifyPeer and startTls options for Redis Standalone usage.

Original pull request: #180.
CLA: 166820160311101157 (Balázs Németh)
2016-03-22 11:00:13 +01:00
Christoph Strobl
4783a0c361 DATAREDIS-427 - Polishing.
Use ShadowingClassLoader instead of a self written one.

Original Pull Request: #179
2016-03-17 14:16:08 +01:00
Mark Paluch
77630d0820 DATAREDIS-427 - Allow construction of customized JdkSerializationRedisSerializer.
We now allow constructing JdkSerializationRedisSerializer using an own class loader and by specifying custom converters.

Using an own class-loader: new JdkSerializationRedisSerializer(classLoader)

Using own converters (Serializer/Deserializer): new JdkSerializationRedisSerializer(new SerializingConverter(), new DeserializingConverter(new DefaultDeserializer(classLoader)))

Original Pull Request: #179
2016-03-17 14:15:46 +01:00
Mark Paluch
77de777da8 DATAREDIS-479 - Upgrade to jedis to 2.8.1.
Update jedis driver to 2.8.1. Use binary method for SSCAN and implement ZSCAN and HSCAN methods. Move ScanOptions to ScanParams conversion to JedisConverters.

Original Pull Request: #178
2016-03-15 14:32:37 +01:00
Mark Paluch
069954ee7a DATAREDIS-476 - Polishing.
Add author and getter method for SSL property. Apply formatting. Create test to validate SSL setting is set correctly in the lettuce driver.

Original pull request: #177.
2016-03-15 09:17:37 +01:00
Balazs Nemeth
a9d8a6b388 DATAREDIS-476 - Add SSL support to LettuceConnectionFactory.
Original pull request: #177.
CLA: 166820160311101157 (Balázs Németh)
2016-03-15 09:17:37 +01:00
Christoph Strobl
8f129b16f9 DATAREDIS-425 - Preserve item order in list, update documentation.
We now preserve the item order when converting list elements. This does not mean that we place elements at the exact position retrieved from the store but rather maintain their order based on the index value.

Additionally applied some documentation polishing and cluster tests.

Original Pull Request: #156
2016-03-14 10:41:58 +01:00
Christoph Strobl
9eb309c495 DATAREDIS-425 - Adapted to changes in Spring Data KeyValue APIs.
Default query initialization changed to new, so we can delete some code here. 

Original Pull Request: #156
2016-03-14 10:41:23 +01:00
Oliver Gierke
2cc30553a8 DATAREDIS-425 - Adapted to changes in Spring Data KeyValue APIs.
We now favor shadowing fields over using protected accessor methods.

Original Pull Request: #156
2016-03-14 10:40:31 +01:00
Mark Paluch
92274a8450 DATAREDIS-425 - Add JSR-310 support, CDI extension and Update reference documentation.
We ship converters for JSR-310 types (LocalDate/Time, ZonedDateTime, Period, Duration and ZoneId) to map between UTF-8-encoded byte[] and JDK 8 date/time types.

We also export Redis Repositories in a CDI environment. Repositories can be injected using @Inject. The CDI extension requires at least RedisOperations to be provided. Other beans like RedisKeyValueAdapter and RedisKeyValueTemplate can be provided by the user. If no RedisKeyValueAdapter/RedisKeyValueTemplate beans are found, the CDI extension creates own managed instances.

Original Pull Request: #156
2016-03-14 10:39:50 +01:00
Christoph Strobl
4362c58a8a DATAREDIS-425 - CRUD operation and index resolution refinements.
- Add a composite IndexResolver implementation that iterates over a given collection of delegate IndexResolver instances and collects IndexedData from those.
- Break up cycle involving ReferenceResolver and let the resolver just returns the raw hash.
- Remove IndexType and use dedicated classes for index definitions.
- Fix pagination error and follow up to changes introduced via DATAKV-123.

Original Pull Request: #156
2016-03-14 10:38:52 +01:00
Rob Winch
059ac9fabb DATAREDIS-425 - Add SpelIndexResolver
This commit adds support for adding an index using SpEL expressions.

Original PR #160
2016-03-14 10:38:20 +01:00
Rob Winch
40c2582302 DATAREDIS-425 - Support distinct indexName
This commit adds support for distinguishing between
the property path that is being indexed and the
name of the index that should be used.

This is useful when you do not want the property
path and index name to be the same. For example,
if you want to use Spel expressions, it may not be
possible to use the path as the name of the index.

Original PR #160
2016-03-14 10:38:12 +01:00
Christoph Strobl
bd7728e6ad DATAREDIS-425 - Add Support for basic CRUD and finder Operations backed by Hashes and Sets.
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
2016-03-14 10:37:53 +01:00
Christoph Strobl
5a85ac47a3 DATAREDIS-472 - Add guards to JedisConnection before casting long to int. 2016-03-04 14:19:41 +01:00
Milan Agatonovic
b630744564 DATAREDIS-472 - Remove guards on pExpire & pSetEx in JedisConnection for values exceeding Integer.MAX_VALUE.
Remove guards and use native driver api for pexpire and psetex which is available in the current jedis distribution.

Original Pull Request: #175
CLA: 165820160303082625 (Milan Agatonovic)
2016-03-04 13:26:05 +01:00
Mark Paluch
0f035982b2 DATAREDIS-468 - Polishing.
Add DecoratedRedisConnection interface to unwrap decorated connections. When running on Redis Cluster, use keys/del instead of lua script because cluster connections do not support lua script execution.

Original pull request: #173.
2016-02-26 09:07:07 +01:00
Christoph Strobl
7024ef33e0 DATAREDIS-468 - Guard multi/exec bocks in RedisCache to allow usage with cluster.
We now guard multi/exec blocks by checking the connection type. This allows to skip those commands when running in cluster.

Original pull request: #173.
2016-02-26 09:07:02 +01:00
Christoph Strobl
02742e3b49 DATAREDIS-467 - Fix cluster multi key commands.
We moved away from returning raw map types and now return dedicated objects for command executions in cluster environment. This allows to maintain node information and collecting results from each and every callback. MGET now returns values according to the key position.

Additionally we now prefix info commands in the cluster with the nodes host:port.

Original pull request: #174.
2016-02-26 08:46:05 +01:00
Christoph Strobl
1e5772d00b DATAREDIS-462 - Polishing.
Updated javadoc, fixed indentation, organize imports and some minor refactoring.

Original Pull Request: #169
2016-02-18 07:41:23 +01:00
Mark Paluch
b58c18f85b DATAREDIS-462 - Support lettuce ClientResources.
Add ClientResources to LettuceConnectionFactory. Add TestClientResources for managed resources during tests and reuse ClientResources as much as possible in tests.

Original Pull Request: #169
2016-02-17 17:26:20 +01:00
Christoph Strobl
0fa1319b8f DATAREDIS-465 - Guard lettuce client shutdown during ConnectionFactory.destroy.
We now guard and log errors during lettuce client shutdown when destroying the ConnectionFactory on ApplicationContext shutdown.
2016-02-17 17:26:20 +01:00
Christoph Strobl
bdea5f6544 DATAREDIS-415 - Polishing.
Update license headers and fix minor code format issues.

Original Pull Request: #168
2016-02-17 10:00:16 +01:00
Mark Paluch
7da09eaa51 DATAREDIS-415 - Handle InterruptedException correctly in RedisMessageListenerContainer.
Set interrupted bit when catching InterruptedException. Exit loops when catching InterruptedException to free resources.

Original Pull Request: #168
2016-02-17 09:59:36 +01:00
Mark Paluch
80f8867763 DATAREDIS-464 - Enhance JavaDoc on RedisStringCommands and StringRedisConnection. 2016-02-16 15:20:54 +01:00
Mark Paluch
1151bcf136 DATAREDIS-316 - Polishing.
Extend JavaDoc documentation. Spelling fixes. Add Expiration.from factory method to create Expiration from all available time units.

Original pull request: #170.
2016-02-16 15:14:26 +01:00
Christoph Strobl
0c6c127b5e DATAREDIS-316 - Add EX/PX, NX/XX options to SET command.
We now support EX/PX and NX/XX arguments along with the SET command for both xetorthio/jedis and mp911de/lettuce.

Jedis 2.8 does not support all combinations of EX/PX and NX/XX. To work around those limitations we delegate to the according set methods to execute related commands or fail fast if there is no way for delegation.

Original pull request: #170.
2016-02-16 15:14:14 +01:00
Christoph Strobl
32c5512dda DATAREDIS-461 - Deprecate support for org.codehaus.jackson based Serializers and Mappers. 2016-02-12 09:50:18 +01:00
Vladimir Tsanev
1781e80717 DATAREDIS-456 - Fix misleading log message created by RedisMessageListenerContainer.
Original Pull Request: #161 (Vladimir Tsanev)
2016-02-10 13:34:36 +01:00
Christoph Strobl
97b88979e7 DATAREDIS-407 - Polishing.
Updated license header, added missing Javadoc, fix indentation and organized imports.

Original Pull Request: #166
2016-02-10 11:09:00 +01:00
Mark Paluch
4131f501a6 DATAREDIS-407 - Add zRangeByLex to ZSetOperations.
We now offer methods for ZRANGEBYLEX on ZSetOperations, BoundZSetOperations as well as via RedisZSet.

Original Pull Request: #166
2016-02-10 11:08:51 +01:00
Christoph Strobl
008836066f DATAREDIS-315 - Remove timeout/password from RedisClusterConfiguration.
Removed duplicate configuration options for timeout and password from RedisClusterConfiguration and use the ones provided via the RedisConnectionFactory.

Original pull request: #158.
2016-02-09 15:40:38 +01:00
Mark Paluch
0ac118fcc0 DATAREDIS-315 - Support password protected Redis Cluster.
Add new config property to configure a password for operations with Redis Cluster. The only driver to support Redis Cluster with password is lettuce but 3.4.Final has a blocker bug that prevents the usage

Original pull request: #158.
2016-02-09 15:40:38 +01:00
Mark Paluch
f18def013a DATAREDIS-315 - Support Redis 3.2 CLUSTER NODES output format.
The CLUSTER NODES converter supports the formats for Redis 3.0 and Redis 3.2.

Original pull request: #158.
2016-02-09 15:40:33 +01:00
Mark Paluch
c105cbb7b6 DATAREDIS-315 - Polishing.
Update documentation and fix spelling in JavaDoc and reference documentation.

Allow node lookup by host/port and node Id to enable flexibility when passing references to Redis Cluster nodes. Parse multiple slot ranges for a cluster node and move CLUSTER NODES parser to Converters.

Use fixed line separator instead of OS-specific line separator, consolidate duplicate code, support clusterSetSlotStable with lettuce 3.4 and set lettuce driver shutdown timeout to zero for long running tests.

Original pull request: #158.
2016-02-09 15:38:52 +01:00
Christoph Strobl
c5047f40c6 DATAREDIS-315 - Add initial support for redis cluster (jedis/lettuce).
Cluster support is based on the very same building blocks as non clustered communication. RedisClusterConnection and extension to RedisConnection handles the communication with the Redis Cluster and translates errors into the Spring DAO exception hierarchy.

Redirects for to a specific keys to the corresponding slot serving node are handled by the driver libraries, higher level functions like collecting information accross nodes, or sending commands to all nodes in the cluster that are covered by RedisClusterConnection utilizing a ClusterCommandExecutor distributing commands accross the cluster and collecting results.

RedisTemplate provides access to cluster specific operations via the ClusterOperations interface that can be obtained via RedisTemplate.opsForCluster(). This allows to execute commands explicitly on a single node within the cluster while retaining de-/serialization features configured for the template.

Original pull request: #158.
2016-02-09 14:53:33 +01:00
Christoph Strobl
1f97623a7c DATAREDIS-443 - Add Support for Spring 4.3 synchronized mode to RedisCache.
As of Spring Framework 4.3.RC1, the `Cache` interface has a new `<T> T get(Object key, Callable<T> valueLoader);` method (see SPR-9254).

If no entry for the given key is found, the `Callable` is invoked to compute/load the value that is then put into redis and returned. Additionally concurrent calls get synchronized so that the `Callable` is only called once.

Using Spring Framework 4.3 failures result in `o.s.c.Cache$ValueRetrievalException` prior versions use `RedisSystemException`.

Original pull request: #162.
2016-02-04 09:13:42 +01:00
Christoph Strobl
239d97195a DATAREDIS-405 - Deprecate support for jredis and srp.
Original pull request: #163.
2016-02-03 11:17:07 +01:00
Christoph Strobl
a446dd3619 DATAREDIS-448 - Fix DefaultSetOperations.intersectAndStore not returning command result.
We now properly return the number of elements in the destination set, has always been null so far, for DefaultSetOperations.intersectAndStore.
2016-01-28 07:59:32 +01:00
Christoph Strobl
d078a63f4c DATAREDIS-431 - Autoselect database configured in LettuceConnectionFactory.
We now actively select the predefined db set via the dbIndex on LettuceConnectionFactory. Fixed some spelling issues along the way.

Original pull request: #157.
2015-11-15 13:37:24 +01:00
欧夺标
130c057acd DATAREDIS-417 - Fix ScanCursor throwing NoSuchElementException for empty scan result.
ScanCursor now retriggers SCAN command for results having a new cursorId but no actual values. This avoids NoSuchElementException for server calls like:

    scan 0 match key*9
      1) 1966080
      2) (empty list or set)

Original Pull Request: #154
CLA Number: 143520151016081625 (Duobiao Ou)
2015-10-16 11:31:36 +02:00