Commit Graph

1171 Commits

Author SHA1 Message Date
John Blum
9bae67eae2 Deprecate redundant ByteUtils.extractBytes(…) method.
Refactors extractBytes(:ByteBuffer) to call getBytes(:ByteBuffer), thereby avoid the NullPointerException by throwing the more appropriate IllegalArgumentException with a descriptive message instead.

See #2733
2023-10-12 16:21:12 -07:00
John Blum
747a7d03ee Refactor code and cleanup compiler warnings in Redis caching infrastructure.
* Apply Java 17 syntax try-with-resources in DefaultRedisCacheWriter execute methods.
* Organize source code
* Edit Javadoc.

Closes #2733
2023-10-12 16:20:46 -07:00
Mark Paluch
df4be6f8b5 Correctly apply Reactive zadd NX/XX command flags.
We now correctly apply if exists/if not exists constraints on the reactive zadd command.

Previously, we only considered upsert which wasn't sufficient to apply xx/nx.

Closes #2731
2023-10-12 10:09:55 +02:00
John Blum
9bd8fda30e Apply additional polishing to ClusterCommandExecutor.
See #2518
2023-10-11 22:44:34 -07:00
Mark Paluch
8be6691c8d Polishing.
Simplify tests. Reuse existing interfaces from Spring. Remove inappropriate nullability annotations and introduce annotations where required.

Replace Future mocking with easier to maintain and to read future method overrides. Remove superfluous code and replace with infrastructure classes provided by Spring Framework.

Consistently name callbacks. Make exception collector concept explicit. Reformat code.

See #2518
Original pull request: #2719
2023-10-11 14:46:39 +02:00
John Blum
781fda6be5 Remove Thread.sleep(…) from ClusterCommandExecutor.collectResults(…).
Replace Thread.sleep(..) with Future.get(timeout, :TimeUnit) for 10 microseconds. As a result, Future.isDone() and Future.isCancelled() are no longer necessary. Simply try to get the results within 10 us, and if a TimeoutException is thrown, then set done to false.

10 microseconds is 1/1000 of 10 milliseconds. This means a Redis cluster with 1000 nodes will run in a similar time to Thread.sleep(10L) if all Futures are blocked waiting for the computation to complete and take an equal amount of time to compute the result, which is rarely the case in practice, given different hardware configurations, data access patterns, load balancing/request routing, and so on. However, using Future.get(timeout, :TimeUnit) is more fair than Future.get(), which blocks until a result is returned or an ExecutionException is thrown, thereby starving computationally faster nodes vs. other nodes in the cluster that might be overloaded. In the meantime, some nodes may even complete in the short amount of time when waiting on a single node to complete.

10 microseconds was partially arbitrary, but no more so than Thread.sleep(10L) (10 milliseconds). The main objective was to give each node a chance to complete the computation in a moments notice balanced with the need to quickly check if the computation is done, hence Future.get(timeout, TimeUnit.MICROSECONDS) for sub-millisecond response times. This may need to be further tuned over time, but should serve as a reasonable baseline for the time being. Additionally, this was based on https://redis.io/docs/reference/cluster-spec/#overview-of-redis-cluster-main-components in the Redis documentation, recommending a cluster size of no more than 1000 nodes.

Add test coverage for ClusterCommandExecutor collectResults(..) method.

Cleanup compiler warnings in ClusterCommandExecutorUnitTests.

Closes #2518
Original pull request: #2719
2023-10-11 14:45:28 +02:00
John Blum
dc0756f94e Polish for Issue #2655 and PR #2672.
See #2655
Original pull request: #2672
2023-10-10 19:07:48 -07:00
Mark Paluch
b5f124cfd8 Terminate stream with error on null values returned by RedisElementReader for top-level elements.
We now emit InvalidDataAccessApiUsageException when a RedisElementReader returns null in the context of a top-level stream to indicate invalid API usage although RedisElementReader.read can generally return null values if these are being collected in a container or value wrapper or parent complex object.

Apply consistent wording to operations documentation.
2023-10-10 19:07:42 -07:00
Christoph Strobl
66b00e286d Update native-image runtime hints.
Closes: #2729
2023-10-09 15:38:15 +02:00
John Blum
2075633809 Upgrade to Jedis 5.0
Adapt to API changes in the Jedis 5.0 driver.
Fix bzPopMaxShouldWorkCorrectly() and bzPopMinShouldWorkCorrectly() tests in JedisClusterConnectionTests.

Jedis 5.0 changed the bzpopmax and bzpopmin Redis commands to no longer return an empty (Array)List internally when evaluating and popping from an empty sorted set. A NullPointerException will be thrown if either bzpopmax or bzpopmin commands are executd on an empty Redis sorted set in Jedis 5.0 (vs. Jedis 4.x):

Closes #2612
Original pull request: #2716
2023-10-04 08:04:37 +02:00
Mark Paluch
d4ba034b28 Refine RedisSerializer implementations.
This commit polishes up method ordering, introduces Javadoc where missing and updates nullability annotations and argument names.

Closes #1097
2023-09-21 14:59:23 +02:00
John Blum
75eed8f11a Polish for #2690.
Closes #2690
Original pull request: #2691
2023-09-13 11:35:15 -07:00
Mark Paluch
ec4370f060 Polishing.
Add missing Override annotations.

See #2690
2023-09-13 11:33:41 -07:00
Mark Paluch
7fbfd5d439 Use Locks instead of synchronized blocks that run blocking operations.
To avoid thread pinning on virtual thread arrangements we now use ReentrantLock instead of a synchronized block.

Closes #2690
2023-09-13 11:33:24 -07:00
Mark Paluch
9e473b5dcd Polishing.
Reorder methods to align with ListOperations. Simplify tests to avoid test noise.

See #2692
Original pull request: #2704
2023-09-12 11:09:06 +02:00
John Blum
157f5e4b1d Adds support to lPop or rPop N elements from a Redis List in ReactiveListOperations.
Closes #2692
Original pull request: #2704
2023-09-12 11:08:32 +02:00
John Blum
ea4acad379 Polish enhanced switch statements.
See #2705
Original pull request: #2706
2023-09-11 16:45:59 -07:00
Junghoon Ban
5e23156f78 Change switch statements to switch expressions.
Remove unused default branches.

Closes #2705
Original pull request: #2706
2023-09-11 16:44:10 -07:00
John Blum
e423851f87 Polish for #2696.
Closes #2701
Original pull request: #2696
2023-09-06 17:15:51 -07:00
Mingyuan Wu
b13690c611 Fix wrong asserted code in ConvertingCursor.
Pull Request: #2696
2023-09-06 16:46:15 -07:00
Mark Paluch
f5f0c3b259 Polishing.
Move executor from ClusterConfiguration to connection factories as the executor is a Spring concept that isn't tied to endpoint details or the client config.

Reorder static factory methods after constructors and property accessors after static factory methods. Inline single-line single-use methods that aren't intended as extension hooks for easier readability.

Disable TaskExecutor disposal on ClusterCommandExecutor.destroy().

Remove NonNull annotations as default non-nullability is defined on the package level.

Simplify tests to use integration tests to avoid excessive mocking.

See #2594
Original pull request: #2669
2023-08-17 10:35:15 +02:00
John Blum
8d6ebb4e99 Add configuration for TaskExecutor used by ClusterCommandsExecutor.
This change allows users to leverage the VirtualThread facilities and AsyncTaskExecutor implementations provided in and by the core Spring Framework as part of our Loom support theme.

Closes #2594
Original pull request: #2669
2023-08-17 10:35:15 +02:00
John Blum
2eaf1746da Polishing.
Organize source code and cleanup compiler warnings.

See #2594
Original pull request: #2669
2023-08-17 10:35:14 +02:00
Mark Paluch
76c1830c57 Polishing.
Replace qualified class name access of inner classes with simple names and imports.

Remove Java 8 guards. Extend supported temporal types in Jsr310Converters. Remove superfluous converter annotations.

Simplify tests.

See #2677
Original pull request: #2681
2023-08-17 09:14:39 +02:00
John Blum
dc09635cc4 Register Converters for Offset java.time types in JSR310Converters.
We now appropriately handle OffsetDateTime and OffsetTime the same as all other java.time types, supported as simple types on Spring application (persistent) entity classes.

Closes #2677
2023-08-17 08:44:15 +02:00
Mark Paluch
372d26ab21 Polishing.
Use Regex to capture the various styles of CLUSTER NODES endpoint representations.

See #2678
Original pull request: #2679
2023-08-16 11:53:57 +02:00
Sorokin Evgeniy
d1908fdbfc Add support for bracket-less IPv6 addresses to CLUSTER NODES Converter.
Closes #2678
Original pull request: #2679
2023-08-16 11:53:36 +02:00
Mark Paluch
76da57e797 Polishing.
Tweak wording around thread-safety. Include notices in connection factories.

Reformat asciidoc.

See #2653
Original pull request: #2667
2023-08-10 11:08:45 +02:00
John Blum
4bf1d06758 Edit ref docs and Javadoc for connection classes to clearly state the Thread-safety guarantees.
Closes #2653
Original pull request: #2667
2023-08-10 11:08:45 +02:00
John Blum
d5642d9e4a Edit class Javadoc in Redis*Configuration classes.
Additionally, fix a few commpiler warnings and organize instance variables by type.

Closes #2586
2023-08-08 13:40:20 -07:00
Mark Paluch
6207a4f771 Polishing.
Replace topic label with assertion message. Reorder methods to align with Spring style.

See #2662
Original pull request: #2663
2023-08-08 10:28:00 +02:00
John Blum
979fb6ac6d Simplify logic in RedisMessageListenerContainer and supporting classes.
Closes #2662
Original pull request: #2663
2023-08-08 10:28:00 +02:00
John Blum
5d297470d1 Fix spelling in SynchronizingMessageListener.SubscriptionSynchronizion.
Additionally, cleanup compiler warnings.

Closes #2656
Original pull request: #2657
2023-08-08 09:43:20 +02:00
Mark Paluch
0b32e7bed1 Polishing.
Use createMono/createFlux syntax instead of using the template for wrapper creation.

See #2658
Original pull request: #2659
2023-08-07 15:52:01 +02:00
John Blum
00737441fd Rename Function Lambda parameter to match command interface in (Default) ReactiveXxxOperations.
Cleanup compiler warning.

Fix unnatural line breaks.

Closes #2658
Original pull request: #2659
2023-08-07 15:51:33 +02:00
Christoph Strobl
5568ffd818 Polishing
Order imports to match code style. Use one line per sentence in documentation.

Original pull request: #2643
2023-08-01 15:02:14 +02:00
John Blum
dddf3530b9 Add support for TTI expiration in Redis Cache implementation.
We now support time-to-idle (TTI) expiration policies for cache reads.

The TTI implementation is achieved with the use of the Redis GETEX command on Cache.get(key) operations as well as consistently using the same TTL configuration for all cache operations when TTI is enabled and TTL expiration has been configured,
with the use of a TtlFunction or fixed Duration.

Closes #2351
Original pull request: #2643
2023-07-28 10:42:34 +02:00
Christoph Strobl
862e3446bc Use reflection to access internal value in tests.
Original Pull Request: #2647
2023-07-28 10:30:15 +02:00
John Blum
e5cec58a40 Fix RedisCommand.requiresArguments for zero argument length.
Closes #2646
Original Pull Request: #2647
2023-07-28 10:30:15 +02:00
John Blum
59a7266ff7 Polish for RedisSerializationContext.
Closes #2651
Original pull request: #2652
2023-07-27 15:51:31 -07:00
zhoukq
a3e35a3340 Assign 'tuple' to 'stringTuple' in DefaultRedisSerializationContextBuilder.string().
Currently, the builder method incorrectly assigns 'tuple' SerializationPair<String> argument to 'hashValueTuple'.

Closes #2651
Original pull request: #2652
2023-07-27 15:50:29 -07:00
Mark Paluch
377ee1804f Polishing.
Make fields final where possible. Reintroduce end of line comment markers to avoid reformatting into unreadable format. Replace HashSet per command instance with String to reduce memory footprint.

Tweak Javadoc wording to represent what we actually expect. Reorder methods.

See #2640
Original pull request: #2644
2023-07-18 10:52:59 +02:00
John Blum
ce8b857a2e Polishing.
Additionally, applied Java 17 syntax, cleaned up compiler warnings, and edited Javadoc.

Closes #2644
Original pull request: #2640
2023-07-18 09:51:52 +02:00
Thach Le
95d5b82ac6 Fix misordered 'final static' modifiers.
Per the Java Language Specification (Java 17; https://docs.oracle.com/javase/specs/jls/se17/html/jls-8.html#jls-8.3.1), 'static' should appear before 'final'.

This is also consistent with source code analysis tools, like Checkstyle, rules: https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.html.

Original pull request: #2640
2023-07-18 09:51:20 +02:00
Mark Paluch
b8a9d5fa0a Polishing.
Use standard assertions. Tweak Javadoc wording.

See #2494
Original pull request: #2645
2023-07-18 09:26:39 +02:00
John Blum
5a12140b49 Make RedisAccessor abstract.
Closes #2494
Original pull request: #2645
2023-07-18 09:26:39 +02:00
Mark Paluch
2e5aed4104 Polishing.
Add documentation for generics. Fix remove() and element() methods to adhere to their contract.

See #2602
Original pull request: #2608
2023-07-13 10:55:55 +02:00
John Blum
a05b25abe5 Adapt RedisList to API changes in Java 21 SequencedCollections.
Closes #2602
Original pull request: #2608
2023-07-13 10:55:55 +02:00
Christoph Strobl
7add798886 Polishing.
Add tests that assert initialization constraints, use early return to default value in case of null and align code format.

Original Pull Request: #2637
2023-07-12 13:53:34 +02:00
Mark Paluch
5d885e24a3 Refine RedisCollectionFactoryBean collection creation.
We now cross-check the existing key type against the specified CollectionType to avoid collection creation that doesn't match the configured CollectionType. If the existing key type doesn't match the configured CollectionType, collection creation fails with a validation error.

Closes #2633
Original Pull Request: #2637
2023-07-12 13:53:03 +02:00