Commit Graph

632 Commits

Author SHA1 Message Date
Mark Paluch
65754623f6 DATAREDIS-864 - Add support for Redis Streams.
We now support Redis Streams to add, read and consume stream records. We introduced StreamOperations, BoundStreamOperations, and ReactiveStreamOperations to interact with Redis Streams using imperative and reactive programming models. Record represents items within a stream. There are various flavors of Stream Records:

* MapRecord (maps to the hash body used in stream messages).
* Binary MapRecord: byte[] and ByteBuffer variants of MapRecord.
* ObjectRecord: Simple and Complex Objects mapped onto the stream body hash using ObjectHashMapper.

Redis Streams are supported for the Lettuce client only as Jedis has not received yet Redis Stream support.

Messages can be created as Map or as object:

redisTemplate.opsForStream().add("my-stream", Collections.singletonMap("key", "value"));

redisTemplate.opsForStream().add(ObjectRecord.create("my-logins", new LoginEvent(…)));

Streams can be consumed by using a StreamMessageListenerContainer that allows for stream subscriptions or a StreamReceiver.

Synchronous Message Listener:

StreamMessageListenerContainer<String, MapRecord<String, String, String>> container = StreamMessageListenerContainer
      .create(connectionFactory);
container.start();

Subscription subscription = container.receive(StreamOffset.fromStart("my-stream"), record -> … );

Reactive Message Receiver:

StreamReceiverOptions<String, ObjectRecord<String, LoginEvent>> receiverOptions = StreamReceiverOptions.builder()
      .targetType(LoginEvent.class).build();

StreamReceiver<String, ObjectRecord<String, LoginEvent>> receiver = StreamReceiver.create(connectionFactory, receiverOptions);

Flux<ObjectRecord<String, LoginEvent>> messages = receiver.receive(StreamOffset.fromStart("my-logins"));

Original Pull Request: #356
2018-11-22 10:46:21 +01:00
Mark Paluch
910e34067b DATAREDIS-875 - Polishing.
Reformat code.

Original pull request: #368.
2018-10-25 14:54:31 +02:00
Christoph Strobl
713a12bce9 DATAREDIS-875 - Omit MappingRedisConverter type hint for primitive type properties.
We now additionally check if the target property is a primitive type and do no longer add the type hint if so.

Original pull request: #368.
2018-10-25 14:53:34 +02:00
Mark Paluch
acd8b6bd4a DATAREDIS-872 - Polishing.
Create unit tests for RedisAtomic counter initialization. Refactor setIfAbsent(…) method to initializeIfAbsent() to not expose additional API methods.

Original pull request: #367.
2018-10-19 12:30:03 +02:00
ningwei
2d4fbc9aa0 DATAREDIS-872 - Fix race condition in RedisAtomic counters initialization.
We now use setIfAbsent to initialize RedisAtomic counters if no initial value was given. Using setIfAbsent turns the initialization into a single atomic step that prevents race conditions of the previously check and set method that required two Redis commands.

Previously, concurrent processes (threads, external changes to Redis) could set the initial value between the existence check and the value set operation that caused the last participant to win.

Original pull request: #367.
2018-10-19 12:27:33 +02:00
Mark Paluch
6132799353 DATAREDIS-881 - Polishing.
Add author tags. Reformat code. Javadoc, add tests.

Original pull request: #363.
2018-10-16 15:02:42 +02:00
Yanming Zhou
8e8861cbcd DATAREDIS-881 - Allow configuration of Lettuce's quiet shutdown period.
LettuceClientConfigurationBuilder now allows configuration of the quiet shutdown period to improve shutdown time of the Netty EventLoop when using non-shared ClientResources.

Original pull request: #363.
2018-10-16 15:00:32 +02:00
Mark Paluch
148b1ae582 DATAREDIS-874 - Polishing.
Reformat code. Add since tags. Extend tests.

Align Javadoc tonality across RedisAtomic… types.

Original pull request: #362.
2018-10-16 12:08:07 +02:00
Graham MacMaster
f2107ef81b DATAREDIS-874 - Implement accumulate/update methods on RedisAtomic[*] classes.
This commit adds the following public methods to RedisAtomicInteger,
RedisAtomicLong, and RedisAtomicDouble:

T accumulateAndGet(T updateValue, BinaryOperator<T> accumulatorFunction);
T getAndAccumulate(T updateValue, BinaryOperator<T> accumulatorFunction);
T updateAndGet(UnaryOperator<T> updateFunction);
T getAndUpdate(UnaryOperator<T> updateFunction);

These methods are primarily useful for doing CAS operations with the
help of Binary/UnaryOperators to generate the new value. They mirror
their counterparts on the AtomicInteger and AtomicLong classes
available in the java.util.concurrent.atomic package.

Original pull request: #362.
2018-10-16 12:08:07 +02:00
Christoph Strobl
45cbb21849 DATAREDIS-869 - Polishing.
Rename parameters and add methods with new nomenclature.

Original Pull Request: #355
2018-09-20 10:49:20 +02:00
Mark Paluch
169b1bd174 DATAREDIS-869 - Adapt to nomenclature change about Master/Replica.
We now renamed RedisStaticMasterSlaveConfiguration and StaticMasterSlaveConnectionProvider to RedisStaticMasterReplicaConfiguration respective StaticMasterReplicaConnectionProvider to reflect changes in Redis nomenclature regarding replication.

Original Pull Request: #355
2018-09-20 10:48:46 +02:00
Mark Paluch
eff0d29723 DATAREDIS-852 - Polishing.
Refactor lower/upper bound retrieval into LettuceConverters for a consistent lower/upper boundary return value. Use minus one (-1) as the upper bound index to always retrieve the last element if the upper boundary is not bounded.

Original pull request: #353.
2018-07-24 15:26:04 +02:00
michele
3a7d871119 DATAREDIS-852 - Return always a lower/upper bound range index using Range.Bound.unbounded() with Lettuce.
We now return in List, String, and ZSet commands a lower/upper bound range index to prevent NullPointerException. Previously, unbounded ranges could render null values that were attempted to cast to primitives.

Original pull request: #353.
2018-07-24 15:24:34 +02:00
Christoph Strobl
2dfe1e2b4e DATAREDIS-843 - Polishing.
Remove usage of deprecated methods, enable ignored test and move to AssertJ.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
a0d8b3a4c6 DATAREDIS-843 - Polishing.
Remove unnecessary unboxing and final keywords from arguments in method signatures.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
191244b1a4 DATAREDIS-843 - Adapt compare-and-set to changed transaction rollback response.
We now consider a transactional rollback that returns an empty EXEC result as rollback for the CAS (compare-and-set) operation. Previously, we checked only that the response of EXEC is not null. A rollback returns an empty list which was previously considered a successful CAS operation.

The code for CAS is now extracted to CompareAndSet and is reused from RedisAtomic implementations.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
322cfabb17 DATAREDIS-849 - Add support for immutable objects.
We now support immutable objects for saving (e.g. object without a provided Id) and loading (i.e. persistence constructor declares a subset of properties). New instances are created using wither methods/Kotlin copy(…) methods if an immutable object requires association with an Id.

Association of the Id to its object moved from RedisKeyValueAdapter to RedisKeyValueTemplate.
2018-07-12 10:44:33 +02:00
jsajadi
3defab118e DATAREDIS-850 - Fix assertion for expireTimeout in ReactiveStringCommands.pSetEx(…).
We now correctly assert the expireTimeout parameter.

Original pull request: #351.
2018-07-09 09:41:29 +02:00
Christoph Strobl
9e74556f74 DATAREDIS-696 - Add support for REPLACE option to RESTORE.
We bypass the lack of driver support by directly executing a custom command.

Original pull request: #344.
2018-07-02 11:44:18 +02:00
Christoph Strobl
caeaab508f DATAREDIS-840 - Polishing.
Introduce dedicated Subscription.close() to unsubscribe() and punsubscribe().

Original Pull Request: #346
2018-06-12 10:34:42 +02:00
Mark Paluch
c9e1803c3a DATAREDIS-840 - Polishing.
Fix code comment. Reformat code.

Original Pull Request: #346
2018-06-12 10:24:48 +02:00
Mark Paluch
bb1dd8b379 DATAREDIS-840 - Catch unsubscribe exceptions when stopping RedisMessageListenerContainer.
We now catch exceptions that may occur during unsubscription from the subscribed patterns/channels.
Previously, RuntimeExceptions were not caught and prevented a fast shutdown of the ApplicationContext.

Original Pull Request: #346
2018-06-12 10:24:08 +02:00
Mark Paluch
afd8606e19 DATAREDIS-842 - Polishing.
Reformat code. Add author tags. Add integration test.

Original pull request: #345.
2018-06-06 12:27:12 +02:00
Ruben Cervilla
e61beb441f DATAREDIS-842 - Consider database index when connecting to Redis using Redis Sentinel.
Original pull request: #345.
2018-06-06 12:23:16 +02:00
Mark Paluch
86606be850 DATAREDIS-771 - Polishing.
Improve error message for unsupported PartTree keywords.

Original Pull Request: #342
2018-05-23 11:15:11 +02:00
Mark Paluch
d73a0e1677 DATAREDIS-771 - Add support for IsTrue and IsFalse keywords in repository query methods.
We now support IsTrue and IsFalse keywords usage in repository query methods to create queries with predicates for boolean fields values without requiring to pass a boolean argument.

class Person {

    @Id String id;

    @Indexed Boolean alive;
}

interface PersonRepository extends Repository<Person, String> {

    Person findByAliveIsTrue();

    Person findByAliveIsFalse();
}

Original Pull Request: #342
2018-05-23 11:14:39 +02:00
Christoph Strobl
127aa26f68 DATAREDIS-830 - Polishing.
Move Subscription initialization and update comments.

Original Pull Request: #341
2018-05-22 12:38:34 +02:00
Mark Paluch
e766b18d8e DATAREDIS-830 - Polishing.
Reformat code. Add override-comments. Encapsulate connection in LettuceSubscription. Fix typos.

Original Pull Request: #341
2018-05-22 12:38:03 +02:00
Mark Paluch
a2bc45cfa2 DATAREDIS-830 - Release Pub/Sub connection when closing LettuceSubscription.
We now release the native connection back to the connection provider when LettuceSubscription is closed. Previously, we just closed the connection which interfered with pooling as pooling connection providers still had a reference on the connection.

Original Pull Request: #341
2018-05-22 12:37:32 +02:00
Christoph Strobl
03c607a337 DATAREDIS-743 - Polishing.
Update Javadoc and comments.

Original Pull Request: #343
2018-05-22 10:46:06 +02:00
Mark Paluch
ee3c1bd9f8 DATAREDIS-743 - Polishing.
Add Javadoc. Improve ScanOptions builder.

Original Pull Request: #343
2018-05-22 10:45:08 +02:00
Mark Paluch
d4b06c2984 DATAREDIS-743 - Add Reactive SCAN, HSCAN, SSCAN, and ZSCAN support.
We now provide reactive SCAN support for keys, hashes, sets, and sorted sets. Scanning uses a cursor-based Flux and takes subscriber demand into account to issue the according scan commands once a batch of keys/values/entries was emitted. Specifying a SCAN limit controls the batch (page) size and can be used to optimize the number of roundtrips between the application and Redis.

Original Pull Request: #343
2018-05-22 10:43:37 +02:00
Christoph Strobl
9b18499b5e DATAREDIS-778 - Align return types of BoundZSetOperations with ZSetOperations.
This is a binary breaking change that requires code using BoundZSetOperations to recompile.

Original pull request: #338.
2018-05-15 15:02:20 +02:00
Christoph Strobl
90f0685cb7 DATAREDIS-824 - Polishing.
Split and add integration tests.

Original Pull Request: #340
2018-05-04 14:02:54 +02:00
Yin Jifeng
2c1ee77b87 DATAREDIS-824 - Fix potential NPE in DefaultReactiveHashOperations when deserializing values.
Avoid ByteBuffer creation for null values indicating absent keys in hash.

Original Pull Request: #340
2018-05-04 14:02:45 +02:00
Mark Paluch
d2871ec032 DATAREDIS-562 - Add reactive BitField support.
Original pull request: #227.
2018-05-03 15:24:23 +02:00
Mark Paluch
10f8553c5a DATAREDIS-562 - Polishing.
Move BitfieldCommand to top-level type BitFieldSubCommands.
Use primitives in command objects. Add toString methods. Add utility methods to extract responses from Jedis Client. Use Connection.execute(…) to invoke BITFIELD using Jedis. Fix Overflow values to string rendering.
Convert test ticket references to new format.

Original pull request: #227.
2018-05-03 15:24:23 +02:00
Christoph Strobl
41db6a10fe DATAREDIS-562 - Add support for BITFIELD.
We now offer support for BITFIELD via RedisConnection and RedisClusterConnection using Lettuce and Jedis.

connection.bitField(key,
  create()
   .set(INT_8).valueAt(offset(0).multipliedByTypeLength()).to(100)
   .incr(signed(8)).valueAt(offset(102)).overflow(FAIL).by(1));

Original pull request: #227.
2018-05-03 15:24:23 +02:00
佳何 蔡
e631352832 DATAREDIS-819 - Fix Javadoc in ReactiveValueOperations.
Original Pull Request: #336
2018-05-03 14:01:05 +02:00
Mark Paluch
0955a4fea6 DATAREDIS-716 - Polishing.
Add OBJECT command support for Jedis Cluster.

Original pull request: #337.
2018-05-02 18:09:53 +02:00
Christoph Strobl
70a3e5dbe7 DATAREDIS-716 - Add support for OBJECT REFCOUNT, ENCODING and IDLETIME.
Original pull request: #337.
2018-05-02 15:53:24 +02:00
Mark Paluch
f8d63f4736 DATAREDIS-822 - Consider argument range in RedisCommand min/max arguments specification.
We now consider max argument specifications as upper bound and no longer as the exact number of required arguments.

Original pull request: #335.
2018-05-02 14:49:24 +02:00
Mark Paluch
abb7d9f684 DATAREDIS-697 - Polishing.
Extract Range value access to methods. Remove unused imports. Add type hint for BITPOS via execute(…).

Original pull request: #335.
2018-05-02 14:31:23 +02:00
Christoph Strobl
e9a3a5b6d9 DATAREDIS-697 - Add support for BITPOS.
We now support the BITPOS command throughout the sync and reactive api.

Original pull request: #335.
2018-05-02 14:31:09 +02:00
Christoph Strobl
8215f68d9f DATAREDIS-815 - Polishing.
Update Javadoc, add tests and missing methods for BoundValueOperations.

Original Pull Request: #334
2018-04-26 14:58:26 +02:00
Mark Paluch
e5b14193d4 DATAREDIS-815 - Add method variants accepting/returning java.time.Duration.
Original Pull Request: #334
2018-04-26 14:11:34 +02:00
Christoph Strobl
f1be9b736d DATAREDIS-786 - Polishing.
Update Javadoc and add setIfPresent to BoundValueOperations.

Original Pull Request: #334
2018-04-26 14:10:15 +02:00
Mark Paluch
2c11a1c402 DATAREDIS-786 - Add ValueOperations.setIfPresent(…).
We now expose setIfPresent(…) through ValueOperations.

Original Pull Request: #334
2018-04-26 14:00:49 +02:00
Christoph Strobl
16f7a445ba DATAREDIS-612 - Polishing.
Introduce dedicated methods utilizing the ReactiveMessageListenerContainer to create a stream of Messages via ReactiveRedisTemplate.

redisTemplate.listenToChannel("channel1", "channel2").doOnNext(msg -> {
    // message processing ...
}).subscribe();

Add close-/destroyLater methods avoiding blocking shutdown of connections and containers.

Original Pull Request: #295
2018-04-26 09:27:34 +02:00
Mark Paluch
a3b96add06 DATAREDIS-612 - Polishing.
Introduce factory methods for ChannelTopic and PatternTopic.

Original Pull Request: #295
2018-04-26 09:20:04 +02:00