|
23 | 23 | import java.util.List;
|
24 | 24 | import java.util.Map;
|
25 | 25 | import java.util.Map.Entry;
|
26 |
| -import java.util.Optional; |
27 | 26 | import java.util.Set;
|
28 | 27 | import java.util.concurrent.TimeUnit;
|
29 | 28 | import java.util.concurrent.atomic.AtomicReference;
|
@@ -219,10 +218,10 @@ public Object put(final Serializable id, final Object item, final Serializable k
|
219 | 218 | rdo.setId(converter.getConversionService().convert(id, String.class));
|
220 | 219 |
|
221 | 220 | if (!(item instanceof RedisData)) {
|
222 |
| - KeyValuePersistentProperty idProperty = converter.getMappingContext().getPersistentEntity(item.getClass()).get() |
223 |
| - .getIdProperty().get(); |
224 |
| - converter.getMappingContext().getPersistentEntity(item.getClass()).get().getPropertyAccessor(item) |
225 |
| - .setProperty(idProperty, Optional.ofNullable(id)); |
| 221 | + KeyValuePersistentProperty idProperty = converter.getMappingContext() |
| 222 | + .getRequiredPersistentEntity(item.getClass()).getRequiredIdProperty(); |
| 223 | + converter.getMappingContext().getRequiredPersistentEntity(item.getClass()).getPropertyAccessor(item) |
| 224 | + .setProperty(idProperty, id); |
226 | 225 | }
|
227 | 226 | }
|
228 | 227 |
|
@@ -441,8 +440,8 @@ public Long doInRedis(RedisConnection connection) throws DataAccessException {
|
441 | 440 |
|
442 | 441 | public void update(final PartialUpdate<?> update) {
|
443 | 442 |
|
444 |
| - final RedisPersistentEntity<?> entity = this.converter.getMappingContext().getPersistentEntity(update.getTarget()) |
445 |
| - .get(); |
| 443 | + final RedisPersistentEntity<?> entity = this.converter.getMappingContext() |
| 444 | + .getRequiredPersistentEntity(update.getTarget()); |
446 | 445 |
|
447 | 446 | final String keyspace = entity.getKeySpace();
|
448 | 447 | final Object id = update.getId();
|
@@ -632,32 +631,28 @@ private <T> T readBackTimeToLiveIfSet(final byte[] key, T target) {
|
632 | 631 | return target;
|
633 | 632 | }
|
634 | 633 |
|
635 |
| - RedisPersistentEntity<?> entity = this.converter.getMappingContext().getPersistentEntity(target.getClass()).get(); |
| 634 | + RedisPersistentEntity<?> entity = this.converter.getMappingContext().getRequiredPersistentEntity(target.getClass()); |
636 | 635 | if (entity.hasExplictTimeToLiveProperty()) {
|
637 | 636 |
|
638 |
| - Optional<RedisPersistentProperty> ttlProperty = entity.getExplicitTimeToLiveProperty(); |
639 |
| - if (!ttlProperty.isPresent()) { |
| 637 | + RedisPersistentProperty ttlProperty = entity.getExplicitTimeToLiveProperty(); |
| 638 | + if (ttlProperty == null) { |
640 | 639 | return target;
|
641 | 640 | }
|
642 | 641 |
|
643 |
| - final Optional<TimeToLive> ttl = ttlProperty.get().findAnnotation(TimeToLive.class); |
| 642 | + TimeToLive ttl = ttlProperty.findAnnotation(TimeToLive.class); |
644 | 643 |
|
645 |
| - Long timeout = redisOps.execute(new RedisCallback<Long>() { |
| 644 | + Long timeout = redisOps.execute((RedisCallback<Long>) connection -> { |
646 | 645 |
|
647 |
| - @Override |
648 |
| - public Long doInRedis(RedisConnection connection) throws DataAccessException { |
649 |
| - |
650 |
| - if (ObjectUtils.nullSafeEquals(TimeUnit.SECONDS, ttl.get().unit())) { |
651 |
| - return connection.ttl(key); |
652 |
| - } |
653 |
| - |
654 |
| - return connection.pTtl(key, ttl.get().unit()); |
| 646 | + if (ObjectUtils.nullSafeEquals(TimeUnit.SECONDS, ttl.unit())) { |
| 647 | + return connection.ttl(key); |
655 | 648 | }
|
| 649 | + |
| 650 | + return connection.pTtl(key, ttl.unit()); |
656 | 651 | });
|
657 | 652 |
|
658 |
| - if (timeout != null || !ttlProperty.get().getType().isPrimitive()) { |
659 |
| - entity.getPropertyAccessor(target).setProperty(ttlProperty.get(), |
660 |
| - Optional.ofNullable(converter.getConversionService().convert(timeout, ttlProperty.get().getType()))); |
| 653 | + if (timeout != null || !ttlProperty.getType().isPrimitive()) { |
| 654 | + entity.getPropertyAccessor(target).setProperty(ttlProperty, |
| 655 | + converter.getConversionService().convert(timeout, ttlProperty.getType())); |
661 | 656 | }
|
662 | 657 | }
|
663 | 658 |
|
@@ -757,7 +752,7 @@ private void initKeyExpirationListener() {
|
757 | 752 | }
|
758 | 753 |
|
759 | 754 | /**
|
760 |
| - * {@link MessageListener} implementation used to capture Redis keypspace notifications. Tries to read a previously |
| 755 | + * {@link MessageListener} implementation used to capture Redis keyspace notifications. Tries to read a previously |
761 | 756 | * created phantom key {@code keyspace:id:phantom} to provide the expired object as part of the published
|
762 | 757 | * {@link RedisKeyExpiredEvent}.
|
763 | 758 | *
|
|
0 commit comments