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.
This commit is contained in:
Mark Paluch
2016-07-12 17:41:34 +02:00
parent c4ddc9e125
commit fd6e4d12ea
4 changed files with 37 additions and 7 deletions

View File

@@ -605,9 +605,9 @@ public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
}
});
if (timeout != null || (timeout == null && !ttlProperty.getType().isPrimitive())) {
if (timeout != null || !ttlProperty.getType().isPrimitive()) {
entity.getPropertyAccessor(target).setProperty(ttlProperty,
NumberUtils.convertNumberToTargetClass(timeout, (Class) ttlProperty.getType()));
converter.getConversionService().convert(timeout, ttlProperty.getType()));
}
}

View File

@@ -282,9 +282,9 @@ public class RedisMappingContext extends KeyValueMappingContext {
} else if (ttlProperty != null) {
RedisPersistentEntity entity = mappingContext.getPersistentEntity(type);
Long timeout = (Long) entity.getPropertyAccessor(source).getProperty(ttlProperty);
Number timeout = (Number) entity.getPropertyAccessor(source).getProperty(ttlProperty);
if (timeout != null) {
return TimeUnit.SECONDS.convert(timeout, unit);
return TimeUnit.SECONDS.convert(timeout.longValue(), unit);
}
} else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ public interface RedisPersistentEntity<T> extends KeyValuePersistentEntity<T> {
boolean hasExplictTimeToLiveProperty();
/**
* Get the {@link PersistentProperty}
* Get the {@link PersistentProperty} that is annotated with {@link org.springframework.data.redis.core.TimeToLive}.
*
* @return can be {@null}.
* @since 1.8