Open GohKianSeng opened 5 months ago
just realised if i used saveAll. the Time to live is set. is that a bug?
Sounds like a bug! Did you just used save
?
yes i used repository.save
hello @bsbodden for saveAll also has issue i guess.
the controller save() has TTL set.
but using PostConstruct doesn't work
Redis Insight
@GohKianSeng I can't seem to be able to replicate the issue, could you create a simple reproducer app? Just models, repository and a CommandLineRunner to run your scenario?
@GohKianSeng I don't think we have added support for @PostConstruct
, that might be the root of the issue here
Hi @bsbodden,
I discovered that in a Spring Boot project, when using spring-boot-devtools, the application runs with the org.springframework.boot.devtools.restart.classloader.RestartClassLoader class loader, instead of the jdk.internal.loader.ClassLoaders class loader (which is used by Spring OM). This difference causes an issue where Spring OM cannot load the KeyspaceConfiguration for an entity in the method:
com.redis.om.spring.RedisJSONKeyValueAdapter.getTTLForEntity(Object entity)
The problem arises because the line:
entityClassKey = ClassLoader.getSystemClassLoader().loadClass(entity.getClass().getTypeName())
returns an entityClassKey that is not present in the KeyspaceConfiguration.settingsMap
In the context of @SpringBootTest, the jdk.internal.loader.ClassLoaders class loader is used, which is why TTL works in the unit test environment, but fails in the application context when spring-boot-devtools is enabled.
A temporary fix for this issue is to disable spring-boot-devtools.
@nexlink-giangbui thanks for the investigation! The RestartClassLoader getting in the way of low level stuff is a recurring theme, I'm looking into ways to get to the correct classloader in that scenario. Stay tuned!
hello this is my entity model. set the time to live but in redis insight, show no limit.
`@Document("TestResultRedis", timeToLive = 5 * 60) data class TestResultRedisModel( @Id val id: Long?,
)`