Commit Graph

401 Commits

Author SHA1 Message Date
Mark Paluch
ea598c2dad DATAREDIS-542 - Fix key expiration for RedisCache.putIfAbsent.
RedisCache now expires keys using putIfAbsent if the key was set. Previously, the key was only expired if the value was already present and the value matched the value stored inside of Redis.

Original Pull Request: #224
2016-10-07 11:30:50 +02:00
Mark Paluch
4c8f1674e4 DATAREDIS-533 - Polishing.
Remove empty lines after last inner class. Extract duplicate code in variable. Fix spelling. Update Reference Documentation. Remove merge leftovers.

Original pull request: #215.
2016-09-13 15:43:28 +02:00
Christoph Strobl
07d0b82100 DATAREDIS-533 - Add support for geo indexes.
We now allow usage of @GeoIndexed to mark GeoLocation or Point properties as candidates for secondary index creation. Non null values will be included in GEOADD command as follows:

    GEOADD keyspace:property-path point.x point.y entity-id

@GeoIndexed can be used on top level as well as on nested properties.

class Person {

	@Id String id;
	String firstname, lastname;
	Address hometown;
}

class Address {
	String city, street, housenumber;
	@GeoIndexed Point location;
}

The above allows us to derive geospatial queries from a given method using NEAR and WITHIN keywords like:

interface PersonRepository extends CrudRepository<Person, String> {

	List<Person> findByAddressLocationNear(Point point, Distance distance);

	List<Person> findByAddressLocationWithin(Circle circle);
}

Partial updates on the Point itself also trigger an index refresh operation. So it is possible to alter existing entities via:

template.save(new PartialUpdate<Person>("1", Person.class).set("address.location", new Point(17, 18));

Original pull request: #215.
2016-09-13 15:43:28 +02:00
Christoph Strobl
5d09272876 DATAREDIS-551 - Polishing.
Fix indentation.

Original Pull Request: #220
2016-09-13 10:10:23 +02:00
Mark Paluch
5aef8c3b0b DATAREDIS-551 - Fix pageable query execution when derived criteria is empty.
We now make sure to count records without using criteria when derived criteria is empty. This allows usage of declared query methods using `Pageable` without criteria like `findBy(Pageable page)`.

Original Pull Request: #220
2016-09-13 10:10:16 +02:00
Mark Paluch
a8462c597e DATAREDIS-547 - Polishing.
Return empty list if offset is greater than the available data set. Update supported keywords in reference docs.

Original pull request: #216.
2016-09-12 14:53:07 +02:00
Christoph Strobl
83ff5ec85b DATAREDIS-547 - Fix query execution when derived criteria is empty.
We now make sure to pipe finder queries without any criteria to the according find all method. This allows usage of `PagingAndSortingRepository.findAllBy(Pageable page)` as well as finders without any criteria like `findTop3By()`.

Original pull request: #216.
2016-09-12 14:52:51 +02:00
Christoph Strobl
58d23dea37 DATAREDIS-531 - Scan commands should use a dedicated bound connection.
SCAN, SSCAN, HSCAN and ZSCAN now reference a dedicated connection that is bound to the Cursor. This allows creation of multiple cursors for different threads without the risk of potentially sharing a single connection. As before the caller is responsible for closing the Cursor correctly after usage.

Original pull request: #218.
2016-09-05 11:23:40 +02:00
Mark Paluch
53c7f80676 DATAREDIS-548 - Release connection after command execution in read-only transactions.
We now unbind and release the connection from the transaction resources after a Redis command is invoked. Redis read operations return always null while using RedisTemplate in a transaction so Redis read transactions are not useful.

Previously, RedisConnection's were bound as transactional resource when used in the scope of a @Transactional(readOnly = true) method but not released on transaction completion. This was, because connections are not registered with a transaction synchronizer.

Original Pull Request: #214
2016-08-30 13:00:31 +02:00
Christoph Strobl
b47fc350e0 DATAREDIS-539 - Replace call to deprecated addCache in RedisCacheManager.
We now rely on getMissingCache and loadCaches for initialization instead of explicitly calling deprecated addCache method.

Original pull request: #212.
2016-08-22 10:51:58 +02:00
Christoph Strobl
eb210a4b8a DATAREDIS-506 - Polishing.
Make use of CollectionUtils and remove duplicate code paths.

Original Pull Request: #211
2016-07-26 15:48:21 +02:00
Mark Paluch
1a332c0f57 DATAREDIS-506 - Upgrade to Jedis 2.9.0.
We now support Jedis 2.9.0 with Redis Standalone SSL and Redis Cluster with passwords. The code is compatible with Jedis 2.8.0 when not using SSL or Redis Cluster with passwords.

Original Pull Request: #211
2016-07-26 15:48:03 +02:00
Christoph Strobl
f606d06b30 DATAREDIS-537 - Polishing.
Move duplicate code into single place and use ternary expressions where applicable.
Use static imports in tests where applicable.

Original Pull Request: #210
2016-07-25 14:46:51 +02:00
Mark Paluch
c7c9a8aab5 DATAREDIS-537 - Add support for Redis Cluster and SSL.
Support SSL, StartTLS and VerifyPeer flags.

Original Pull Request: #210
2016-07-25 14:13:25 +02:00
Mark Paluch
fd6e4d12ea DATAREDIS-523 - Polishing.
Allow reading of the TTL into primitive properties. Allow general numeric types for TTL properties. Extend date range in license headers. Extend JavaDoc.

Original pull request: #208.
2016-07-13 08:51:48 +02:00
Christoph Strobl
c4ddc9e125 DATAREDIS-523 - Read back TTL into property.
We now read back TTL value from Redis for explicitly @TimeToLive annotated properties.

Original pull request: #208.
2016-07-13 08:51:16 +02:00
Mark Paluch
e8a30a79a0 DATAREDIS-526 - Allow using ttl and pttl with TimeUnit on connection-level.
We now support ttl and pttl accepting a TimeUnit on connection level to return the TTL in the requested time unit. By performing the conversion inside the connection we return correct results for plain, pipelining and transaction execution. Add also JavaDoc and @Override to ttl/pttl methods.

Original pull request: #205.
2016-07-08 08:50:56 +02:00
oudb
e64f84b45a DATAREDIS-526 - Fix getExpire return value.
getExpire returns now negative values without time unit conversion in case of absent values or values without a TTL set.

CLA: 143520151016081625 (Duobiao Ou)
Original pull request: #205.
2016-07-08 08:50:30 +02:00
Christoph Strobl
f5a506cb8d DATAREDIS-530 - Fix PartialUpdate removing existing indexes.
We now make sure to leave existing indexes untouched when using PartialUpdate.
We also fixed a glitch, where index values have not been removed correctly when saving entities with null values, along the way.

Original pull request: #207.
2016-07-06 14:34:29 +02:00
Christoph Strobl
0d24b5a573 DATAREDIS-524 - Polishing.
Some formatting changes.

Original Pull Request: #204
2016-07-06 14:16:18 +02:00
Mark Paluch
ea33cd40e6 DATAREDIS-524 - Use password to connect Redis nodes using Sentinel.
LettuceConnectionFactory and DefaultLettucePool now use the configured password to authenticate with Redis. Authentication is applied when connecting to nodes that were obtained from Redis Sentinel.

Original Pull Request: #204
2016-07-06 14:16:08 +02:00
Mark Paluch
74a5652ff0 DATAREDIS-505 - Polishing.
Extend date range in license header. Retrieve connection and config for possible reconfiguration only if keyspaceNotificationsConfigParameter has a value.

Original pull request: #202.
2016-06-17 13:07:31 +02:00
Christoph Strobl
65c7b2c23e DATAREDIS-505 - Allow configuration of Redis Keyspace events config value.
We now allow setting the desired notify-keyspace-events server configuration via @EnableRedisRepsoitories. Use `null` or an empty String for not touching the server’s config. The default is `Ex`.

Original pull request: #202.
2016-06-17 13:07:20 +02:00
Mark Paluch
64456ea134 DATAREDIS-500 - Polishing.
Apply formatting rules. Use differing serializers in test.

Original pull request: #190.
2016-06-17 09:35:57 +02:00
Anqing Shao
73c8ce2009 DATAREDIS-500 - Use Hash Key and Hash Value serializers in RedisTemplate executePipelined(…).
RedisTemplate executePipelined(RedisCallback) uses now the Hash Key and Hash Value serializers to deserialize the response.

Original pull request: #190.
CLA: 174020160421053943 (Anqing Shao).
2016-06-17 09:35:57 +02:00
Christoph Strobl
67106bc75a DATAREDIS-510 - Fix caching of null values.
We now no longer add empty byte[] as cache value but return null instead.

Original pull request: #201.
2016-06-14 16:56:47 +02:00
Christoph Strobl
7af8fdf946 DATAREDIS-513 - Fix RedisServerCommands.time() failure when in pipeline mode.
We fixed a glitch in Jedis/Lettuce RedisConneciton TIME command when used in pipeline or transaction mode.

Original pull request: #199.
2016-06-02 09:33:19 +02:00
Christoph Strobl
2b51966768 DATAREDIS-514 - Unify geoRadius capitalization.
Unify capitalization of geoRadius to match other geo prefixed operations.

Original pull request: #200.
2016-05-27 09:36:38 +02:00
Mark Paluch
d88d992f6d DATAREDIS-471 - Polishing.
Update reference documentation. Enhance JavaDoc. Remove destroy of managed bean. Refactor property update of writePartialUpdate into own method. Remove trailing whitespaces in JavaDoc.

Original pull request: #191.
2016-05-25 16:36:46 +02:00
Christoph Strobl
76229c10a4 DATAREDIS-471 - Add support for partial updates.
We now allow partial update of domain types via PartialUpdate. The according expiration times and secondary index structures are updated accordingly.

In some cases it is not necessary to load and rewrite the entire entity just to set a new value within it. A session timestamp for last active time might be such a scenario where you just want to alter one property.
`PartialUpdate` allows to define `set`, `delete` actions on existing objects while taking care of updating potential expiration times of the entity itself as well as index structures.

.Sample Partial Update
====
[source,java]
----
PartialUpdate<Person> update = new PartialUpdate<Person>("e2c7dcee", Person.class)
  .set("firstname", "mat")                                                           <1>
  .set("address.city", "emond's field")                                              <2>
  .del("age");                                                                       <3>

template.update(update);

update = new PartialUpdate<Person>("e2c7dcee", Person.class)
  .set("address", new Address("caemlyn", "andor"))                                   <4>
  .set("attributes", singletonMap("eye-color", "grey"));                             <5>

template.update(update);

update = new PartialUpdate<Person>("e2c7dcee", Person.class)
  .refreshTtl(true);                                                                 <6>
  .set("expiration", 1000);

template.update(update);
----
<1> Set the simple property _firstname_ to _mat_
<2> Set the simple property _address.city_ to _emond's field_ without having to pass in the entire object. This does not work when a custom conversion is registered.
<3> Remove the property _age_.
<4> Set complex property _address_.
<5> Set a map/collection of values removes the previously existing map/collection and replaces the values with the given ones.
<6> Automatically update the server expiration time when altering time to live.
====

NOTE: Updating complex objects as well as map/collection structures requires further interaction with Redis to determine existing values which means that it might turn out that rewriting the entire entity might be faster.

Original pull request: #191.
2016-05-25 16:36:46 +02:00
Mark Paluch
0e17c9b58d DATAREDIS-491 - Polishing.
Set EnableRedisRepositories.enableKeyspaceEvents default to OFF. Expiry notifications require to opt-in. Add JavaDoc. Add documentation for delayed/disabled event listener. Fix spelling. Use property value instead of attribute on RedisKeyValueAdapter bean definition. Remove trailing white spaces.

Original pull request: #193.
2016-05-25 16:36:35 +02:00
Christoph Strobl
62c704d58a DATAREDIS-491 - Add configuration option to tune KeyspaceEventMessageListener usage.
We now allow more fine grained setup for usage of Redis keyspace events. This can be done programmatically via the RedisKeyValueAdapter or using `@EnableRedisRepositories.enableKeyspaceEvents`.

Original pull request: #193.
2016-05-25 15:25:05 +02:00
Christoph Strobl
46f07d7056 DATAREDIS-512 - Skip repository index update checks on insert.
We now skip checking for existing index values on insert.

Related tickets: DATAREDIS-504.
Original pull request: #198.
2016-05-24 09:33:55 +02:00
Christoph Strobl
f732b5f6b9 DATAREDIS-438 - Polishing.
RedisGeoCommands now take and return Spring Data domain types like Distance and GeoResults.
Updated JavaDoc and Reference documentation.
Added and updated author and license headers.
Fixed minor formatting and code style issues.

Original Pulll Request: #187
2016-05-23 07:07:50 +02:00
Ninad Divadkar
b0e20d3da8 DATAREDIS-438 - Add support for geo commands.
Original Pulll Request: #187
CLA: 169220160326121428 (Ninad Divadkar)
2016-05-18 16:04:45 +02:00
Mark Paluch
83359a9c4f DATAREDIS-469 - Polishing.
Return zero (0) in getAndSet to prevent NullPointerExceptions. Remove trailing whitespace. Add tests for existing methods. Simplify tests.

Original pull request: #182.
2016-05-13 14:35:27 +02:00
Christoph Strobl
20cfd3e76c DATAREDIS-469 - Throw DataRetrievalFailureException for atomic numbers when key is removed.
We now throw DataRetrievalFailureException in case of get() when the underlying key storing the value of an AtomicInteger, AtomicLong or AtomicDouble is removed from Redis.

Original pull request: #182.
2016-05-13 14:34:55 +02:00
Mark Paluch
d097a64bc6 DATAREDIS-423 - Polishing.
Extend documentation. Reformat JavaDoc. Adjust test method names.

Original pull request: #197.
2016-05-13 12:50:49 +02:00
Christoph Strobl
568e41f8dd DATAREDIS-423 - Add support for Jackson2 based HashMapper.
Added FasterXML Jackson `ObjectMapper` based `HashMapper` implementation that allows flattening.

```java
class Person {
  String firstname;
  String lastname;
  Address address;
}

class Address {
  String city;
  String country;
}
```

```bash
firstname:Jon
lastname:Snow
address:{ city : Castle Black, country : The North }

firstname:Jon
lastname:Snow
address.city:Castle Black
address.country:The North
```

Original pull request: #197.
2016-05-13 12:49:46 +02:00
Christoph Strobl
16b692c899 DATAREDIS-509 - Fix handling of primitive arrays in MappingRedisConverter.
We now correctly convert arrays of primitive values.

Original pull request: #196.
2016-05-09 14:59:39 +02:00
Mark Paluch
ebbcd95c6d DATAREDIS-507 - Do not destroy RedisConnectionFactory in RedisKeyValueAdapter.destroy.
Do not destroy RedisConnectionFactory which is likely managed outside of RedisKeyValueAdapter. 
This change makes sure to retain a working connection factory while shutting down message listeners as those try to unsubscribe on shutdown.

Original Pull Request: #195
2016-05-04 08:36:31 +02:00
Mark Paluch
c1476b701b DATAREDIS-503 - Polishing.
Rename ConvertingHashMapper to ObjectHashMapper. Add fromHash with type to avoid casting. Add JavaDoc documentation to HashMapper. Add hash mapping to reference documentation.

Original pull request: #194.
2016-05-02 09:07:10 +02:00
Christoph Strobl
359c3e4533 DATAREDIS-503 - Add HashMapper implementation based on MappingRedisConverter.
We now support mapping of simple and complex types to Redis HASH structures applying the same structure as the Repository support. This allows Object to hash Mapping and its direct usage via RedisTemplate without the need of explicitly having to use the repository abstraction.

Original pull request: #194.
2016-05-02 09:06:28 +02:00
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