Commit Graph

728 Commits

Author SHA1 Message Date
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
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
Christoph Strobl
3d7a524474 DATAREDIS-435 - Fix potential NPE in RedisTestProfileValueSource. 2015-10-27 09:30:32 +01:00
Christoph Strobl
df4ad35057 DATAREDIS-417 - Add failing tests for ScanCursor throwing NoSuchElementException.
Add failing tests for scanning key sets where Redis returns a scan iteration pointing to the next cursor but having no actual values itself like in:

    scan 0 match key*9
      1) 1966080
      2) (empty list or set)
2015-10-16 11:31:28 +02:00
Christoph Strobl
74ea61c51c DATAREDIS-421 - Fix NPE when using HashMapper implementations.
We now make sure the available HashMapper implementations avoid exposing null values. Prior to this null values would have been added to the converted Hash causing trouble when saving those to redis since hashes are expected to not contain any null values
2015-08-31 14:19:39 +02:00
Christoph Strobl
35424bb9da DATAREDIS-392 - Add Gerneric Jackson2 RedisSerializer.
We introduced GenericJackson2JsonRedisSerializer holding a preconfigured ObjectMapper which writes Class type informations into the JSON structure. This enables polymorphic deserialization and allows RedisCache manager to operate upon a RedisTemplate storing data in JSON format, which had until this only been possible using the Jdk Serializer.
2015-08-31 14:09:22 +02:00
Christoph Strobl
444b290863 DATAREDIS-348 - Polishing.
Fixed connection problems leaving sockets open. Added missing JUnit rules for Sentinels. Added missing author information update, license header and Javadoc.

Upgraded test script to use Redis 3.0.2. Upgrade test script to shut down Redis in case of test errors. Added Redis 3.0 to TestProfileValueSource. Enabled ZRANGEBYLEX tests for lettuce.

Original pull request: #144.
Related pull request: #104.
2015-08-04 10:12:39 +02:00
Mark Paluch
7426b27688 DATAREDIS-348 - Switch to mp911de/lettuce 3.0.
Updated lettuce redis client to latest snapshot, adopt changed API and use API for commands which were emulated using LUA script

Implemente Sentinel support using lettuce library, adopt finer grained exceptions and aligned exception behavior to match other libraries. Added shutdown-timeout property in order to control shutdown duration of the netty framework which reduces test run duration. Documentation updated as well. Contains also a fix to use psetex instead of setex (typo).

Switch to Jedis for Redis Version discovery in tests. Polished documentation. Use LettuceConverter and native time() method.

Original pull request: #144.
Related pull request: #104.
2015-08-04 10:12:39 +02:00
Christoph Strobl
7073502e42 DATAREDIS-416 - RedisCache.putIfAbsent(…) now returns null for first addition.
We now return null for RedisCache.putIfAbesent(…) when value is set to meet the contract defined by org.springframework.cache.Cache.putIfAbsent(…).

Original pull request: #150.
2015-07-28 13:42:10 +02:00
Christoph Strobl
aa04e73dbd DATAREDIS-402 - RedisCache should not expire known keys in case ttl of element is not set.
We now skip defining expire on known keys set in case element is eternal.

Original pull request: #141.
2015-06-16 09:38:54 +02:00
Thomas Darimont
31351b0463 DATAREDIS-352 - Enhance range options for ZSET.
Raising required redis version for zRangeByLexTest to fix failing test on CI server.
2015-05-22 18:59:54 +02:00
Christoph Strobl
283a9638f2 DATAREDIS-352 - Enhance range options for ZSET.
We now allow usage of Range and Limit types (newly introduced for ZRANGEBYLEX) on mostly all ZSET range operations.
Extracted constants for plus/minus and -inf/+inf expressions.

Original pull request: #138.
2015-05-22 15:16:08 +02:00
Christoph Strobl
ff37da5197 DATAREDIS-378 - Add support for ZRANGEBYLEX.
We now support ZRANGEBYLEX on RedisConnection and StringRedisConnection when using the Jedis driver. The upper and lower bounds can be defined using the Range type which will be converted to the according binary representation including prefix and/or infinite operators.

	range().gt("a")          => (a +
	range().gte("a")         => [a +
	range().lt("z")          => - (z
	range().lte("z")         => - [z
	range().gte("a").lt("z") => [a (z
2015-04-13 14:15:10 +02:00
Thomas Darimont
cf4fa9e4fb DATAREDIS-332 - @Transactional operation should use the same connection.
We only unbind the current redisConnectionFactory from the current thread if the transaction is not active anymore.
Previously we performed the unbinding in RedisTemplate.execute(RedisCallback, boolean, boolean) overtime which lead to the fact that the next redis operation within the same transaction used a different redis connection, which could lead to exhaustion of the connection pool.
We also ensure that we correctly unbind the RedisConnectionFactory resource from the TransactionSynchronizationManager on transaction completion in RedisTransactionSynchronizer.afterCompletion(int).
Added test case supplied from issue.

Original pull request: #134.
2015-04-13 12:58:54 +02:00
Thomas Darimont
a8e4659f75 DATAREDIS-375 - Avoid repeatedly decorating a cache.
Previously a transactional RedisCacheManager decorated a cache with the TransactionAwareCacheDecorator twice. We now make sure that a particular cache is only decorated once with a TransactionAwareCacheDecorator.

Original Pull Request: #128
2015-03-04 17:28:32 +01:00
Christoph Strobl
c662c46d02 DATAREDIS-372 - Allow easier RedisSentinelConfiguration setup.
We now allow to initialize a RedisSentinelConfiguration based on a given String collection of host:ports.
  sentinelHostAndPorts[0] = 127.0.0.1:23679
  sentinelHostAndPorts[1] = 127.0.0.1:23680

Further on it’s possible to pass in a PropertySource containing master name and sentinel nodes.
  spring.redis.sentinel.master=myMaster
  spring.redis.sentinel.nodes=127.0.0.1:23679,127.0.0.1:23680

Original pull request: #126.
2015-02-16 15:16:09 +01:00
Christoph Strobl
b242d4ac6d DATAREDIS-369 - Avoid resource leak in RedisCache.
We now check the presence of a prefix which allows to identify the keys associated with the cache to either keep track of keys or use the prefix to remove them on clear.

This is a small fix intended to be back ported to the Evans (1.4.x) release train. Additional refactoring will be done for the Fowler release.

Original Pull Request: #122
2015-02-05 08:32:36 +01:00
Thomas Darimont
0ea0c4bf67 DATAREDIS-328 - RedisCacheManager should not instantiate caches in setCacheNames().
We now construct the caches for the configured cache-names in afterPropertiesSet(). Previously the caches were created in the setter which lead to unwanted property-set order dependencies.

Original pull request: #123.
2015-02-02 14:54:05 +01:00
Thomas Darimont
e72514143e DATAREDIS-356 - Check NonTransientDataAccessException for NOSCRIPT error.
We now check for a NonTransientDataAccessException instead of just an UncategorizedDataAccessException to conver all relevant exception types.
Corrected typo in method name. Added infrastructure for driver specific DefaultScriptExecutorTests.
Removed usage of RelaxedJunit4ClassRuner and using MinimumRedisRule
instead.
Removed obsolete test context configuration for ScriptExecutorTests.

Original pull request: #115.
2014-11-28 10:10:01 +01:00
Christoph Strobl
cb070c1375 DATAREDIS-358 - Precise version resolution within RedisTestProfileValueSource.
We now resolve the precise redis version including patch level for the 2.8 line. This allows us to disable tests when building against older versions that might not have the complete featureset available.
2014-11-27 22:03:24 +01:00
Christoph Strobl
22aa5df73e DATAREDIS-308 - Add support for HyperLogLog.
We added methods for PFADD, PFCOUNT and PFMERGE to RedisConnection and StringRedisConnection. HyperLogLogOperations available via RedisTemplate allow more indrect usage of HLL.

Please note that currently Jedis is the only driver that can be used for HyperLogLog commands.

Original pull request: #116.
2014-11-26 15:59:11 +01:00
Christoph Strobl
57fc58fcff DATAREDIS-288 - Polishing.
Added javadoc and assertions to ensure failing before actually sending data to redis and backed those with tests.

Original pull request: #114.
2014-11-17 13:13:08 +01:00
David Liu
d89773387a DATAREDIS-288 - Improved support for collection parameters in ListOperations.
Added additional leftPushAll and rightPushAll method overloads that accept a Collection parameter.
Previously we only accepted varargs which required users to convert collections to arrays.

Based on David Liu's pull request: #100.

Original pull request: #114.
2014-11-17 13:03:13 +01:00
Thomas Darimont
cf46d6e766 DATAREDIS-106 - Support for open interval for scores for sorted sets.
We now support open zset's interval for JedisConnection, JredisConnection, LettuceConnection, SrpConnection and DefaultStringRedisConnection.

Original pull request: #97.
2014-10-29 11:53:03 +01:00
Christoph Strobl
5ca672d180 DATAREDIS-347 - Fix unintended duplicate script execution.
We now inspect the message of the exception thrown to determine whether the error resulted from a script not being present or an other error. In case the script is not present we simply invoke eval.

Original pull request: #108
2014-10-24 19:24:56 +02:00
David Liu
4711693669 DATAREDIS-334 - Add binary alternative for RedisScriptingCommands.evalSha.
Introduced new evalSha method that accepts a byte[] as scriptSha as well
as a variable number of byte[] as keyValueArgs.

Original pull request: #99.
2014-10-09 16:13:27 +02:00
David Liu
9ecad07587 DATAREDIS-197 - Expose bit-related ops via ValueOperations.
Polishing. Added -S switch to gradlew in makefile for better Stacktrace reporting.

Original pull request: #96.
2014-09-30 10:28:53 +02:00
Christoph Strobl
4c7e405f7b DATAREDIS-344 - Assert RedisCache works with Spring 4.1.
Added `putIfAbsent` to `RedisCache` to satisfy compatibility with newly introduced method.

Original pull request: #102.
2014-09-04 15:02:19 +02:00
Thomas Darimont
5abfa8716e DATAREDIS-337 - Improve handling of overridden methods in MessageListenerAdapter.
Previously overriding message handler methods of the delegate passed to MessageListenerAdapter resulted in the message handler method called multiple times. We now make sure that a message handler method is only found and invoked  once.

Original pull request: #95.
2014-08-13 08:53:49 +02:00
Christoph Strobl
fd361a1868 DATAREDIS-330 - Add support for SENTINEL commands.
add support for commands:
  SENTINEL FAILOVER master
  SENTINEL SLAVES master
  SENTINEL REMOVE name
  SENTINEL MONITOR name ip port quorum

Original pull request: #92.
2014-08-11 09:12:12 +02:00
Christoph Strobl
55ff415a71 DATAREDIS-324 - Add Redis Sentinel support.
We’ve added RedisSentinelConfiguration holding required information for connecting to redis sentinels. This can be used to set up ConnectionFeactory for HA environments.

**Using Jedis**
Providing RedisSentinelConfiguration will force the JedisConnectionFactory to use JedisSentinelPool for managing resources.

**Using Lettuce/JRedis/SRP**
There’s currently no support for sentinel in those clients.

**CI Build**
We’ve added makefile to build and set up redis instances for testing sentinel support on travis-ci. There’s already a section for redis cluster.
The cluster section is for whatever reason currently not working as the cluster nodes won’t start.
This will be fixed when we add redis-cluster support.

_side note:_ there’s an alternative fork of lettuce at mp911de/lettuce that already has sentinel support.
2014-08-05 09:00:15 +02:00
Thomas Darimont
5f48ea8ed4 DATAREDIS-317 - Report inappropriate RedisTemplate more eagerly in RedisAtomic wrappers.
We now validate the given RedisTemplate in the constructor of RedisAtomicLong/RedisAtomicInteger/RedisAtomicDouble to report an inappropriate RedisTemplate more eagerly.

Original pull request: #83.
2014-06-30 08:13:26 +02:00
Christoph Strobl
42ff3ee1e1 DATAREDIS-314 - Add SCAN commands to Collection types.
Add scan to RedisMap / RedisSet / RedisZSet.
Lua scritps have to be assembled in binary way in order to avoid script errors when executing.
Add missing rules/profiles to run properly in a 2.6.x redis environment.

Original pull request: #82.
2014-06-17 10:18:28 +02:00
Christoph Strobl
d8b53a4c96 DATAREDIS-313 - Overhaul SCAN, HSCAN, SSCAN, ZSCAN operations.
Unify naming and return types. Update supported commands documentation. Remove key from BoundHashOperations and use getKey() instead.

Original pull request: #81.
2014-06-10 16:10:28 +02:00
Christoph Strobl
c939c8a9ff DATAREDIS-306 - Add support for ZSCAN.
ZSCAN is directly supported by jedis and can be emulated for lettuce via eval.

SRP and JRedis will throw UnsupportedOperationException.

Original pull request: #80.
2014-06-06 01:15:26 +02:00
Christoph Strobl
ba88249188 DATAREDIS-305 - Add support for HSCAN.
HSCAN is directly supported by jedis and can be emulated for lettuce via eval.

SRP and JRedis will throw UnsupportedOperationException.

We have modified the ScanCursor implementation to take Collection instead of List.

Currently naming for scan commands is not consistent for scan, sscan and hscan. There’s a clean up task for those commands when done with all scan related commands.

Original pull request: #78.
2014-06-03 11:50:55 +02:00
Thomas Darimont
1831ae9db7 DATAREDIS-296 - Upgrade jedis to recent version.
Upgrading to latest jedis version 2.5.1. Added new conversion for Long to byte[] in JedisConverters to be able to convert long cursorIds to byte[].

Original pull request: #77.
2014-06-02 08:27:43 +02:00
Thomas Darimont
29e70b8cd8 DATAREDIS-309 - Refactor test profiles to support more than 2 versions.
We’ve added a customized SpringJUnit4Runner and TestRule that allow us to use a more relaxed strategy when dealing with @IfProfileValue. Basically we have added ‘+’ as sort of wildcard indicating tests should be executed for version X and all its successor.

This allows us to run test valid starting 2.6 for 2.8 as well, while those only valid for 2.8 are not executed against eg. redis 2.6.17.

Fixed compile error in ScanCursor with Java 6.

Orignal pull request: #76.
2014-05-28 18:24:37 +02:00
Christoph Strobl
34d1759b4e DATAREDIS-304 - Add support for SSCAN command.
SSCAN command is natively supported by jedis and can be emulated for lettuce.
JRedis and SRP will throw UnsupportedOperationException.

sScan is available on RedisConneciton and RedisSetOperations returning basically a Cursor that allows iteration over the defined values for a given key.

Currently the jedis driver does not directly expose the binary version of sscan which leads to invalid results when using a non String compatible converter along with the RedisTemplate. We’ll change this as soon as a newer version of jedis is available.

Along the way loading behavior of ScanCursor has been fixed, preventing it from indicating next values available when there effectively are no more.

Orignal pull request: #76.
2014-05-28 14:34:18 +02:00
Christoph Strobl
d427928386 DATAREDIS-290 - Add support for SCAN command.
SCAN is currently only supported by jedis but can be emulated for
lettuce via eval.
Srp and JRedis will respond with UnsupportedOperationException.

We provide a Cursor implementation allowing to scroll through the
responses provided by the underlying connection. The cursor will fetch
additional results from redis server whenever its starting point has not
been reached and there are no more already loaded items available.

Only values returned by the last call to redis server are kept in memory
which allows scrolling through the entire collection without potentially
running into memory issues.

Original pull request: #71.
2014-05-23 14:07:11 +02:00
Andy Wilkinson
bdea1051de DATAREDIS-299 - Assert compatibility with Spring IO.
Upgrade to JUnit 4.11

Upgrade to JUnit 4.11 and remove use of a matcher in an internal
package in favour of the Hamcrest equivalent. To avoid a clash between
JUnit 4.11's Hamcrest dependency and the version of Hamcrest that's
bundled in mockito-all, use of mockito-all has been replaced with
mockito-core

Add the Spring IO plugin

Configure the Spring IO plugin such that it's only applied when the
build is run with -PplatformVersion=<version>. This platformVersion
property is used to determine the version of the Platform that will
be used when running the springIoCheck task. The plugin can be used
by running a build as follows:

./gradlew clean springIoCheck -PplatformVersion=1.0.0.BUILD-SNAPSHOT -PJDK7_HOME=… -PJDK8_HOME=…

This will test the project on JDK7 and JDK 8 using the dependencies
defined in the latest snapshot of Spring IO Platform 1.0.0.

Address Java 6 compilation problem

The JUnit and Hamcrest upgrades caused a compilation error on Java 6
due to a bug in the compiler’s handling of generics. This commit adds
more type information to help to guide the compiler around the problem.

Additionally, deprecation warnings caused by the JUnit and Hamcrest
upgrades have also been addressed.

Original pull request: #72.
2014-05-19 09:59:06 +02:00
Christoph Strobl
c38c5f3c09 DATAREDIS-300 - Fix inconsistency with connection open() and close().
Redis connections have been left open when calling RedisTemplate.execute as the connection might have been bound to a thread, released but never been unbound. We now only bind and unbind connections in case of enabled transaction support, while just getting and releasing it for all other purposes.

Original pull request: #69.
2014-05-16 14:22:06 +02:00
Christoph Strobl
ce8d932a46 DATAREDIS-226 - Syntax exceptions using lettuce should be reported immediately.
If running in transaction mode we now do a rudimentary check if the provided number of arguments matches the ones defined for the RedisCommand to execute.

If the command passes this first check and causes an error on redis server one has to check results for Command.getOutput().hasError().

Original Pull Request: #66.
2014-04-29 13:23:20 +02:00