Skip to content

@RedisHash timeToLive is a long, which is not compatible with the use of spring-style / SPeL #2931

Closed as not planned
@alexisgayte

Description

@alexisgayte

org.springframework.data.redis.core.RedisHash has a field timeToLive typed as long therefor you cannot use SPeL/Spring-style expression.

timeToLive is often a property coming from env properties and therefor pass from parameter.
The current definition of @RedisHash is @RedisHash(value="myIndex", timeToLive=60)

The issue seems to come from a long running issue (compiler issue) here @scheduled
image

However this is annoying because that force user of @RedisHash to define all index/entity globally using RedisMappingContext bean

    @Bean
    public RedisMappingContext keyValueMappingContext() {
        return new RedisMappingContext(new MappingConfiguration(new IndexConfiguration(), new MyKeyspaceConfiguration()));
    }

    public class MyKeyspaceConfiguration extends KeyspaceConfiguration {

        @Override
        protected Iterable<KeyspaceSettings> initialConfiguration() {
            KeyspaceSettings keyspace = new KeyspaceSettings(Index.class, "myindex:Index");
            keyspace.setTimeToLive(MyIndex.getTtlInSeconds().longValue());
            return Collections.singleton(keyspace);
        }
    }

linked to : spring-projects/spring-boot#41256

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions