redis / redis-om-spring

Spring Data Redis extensions for better search, documents models, and more
MIT License
599 stars 93 forks source link

Time to live not set when using save when using `@PostConstruct` #458

Open GohKianSeng opened 3 months ago

GohKianSeng commented 3 months ago

hello this is my entity model. set the time to live but in redis insight, show no limit.

image image

`@Document("TestResultRedis", timeToLive = 5 * 60) data class TestResultRedisModel( @Id val id: Long?,

@Searchable
val uuid: String?,

@Searchable
val uatId: String?,

@Searchable
val msgType: String?,

@Searchable
val filename: String?,

@Searchable
val status: String?,

@Searchable
val result: String?,

val overrideStatus: String?,

val remarksSnapshotId: Long?,

@Searchable
val actualCodes: List<String>,

val mappedActualCodes: List<String>,

@Searchable
val expectedCodes: List<String>,

val mappedExpectedCodes: List<String>,

@Searchable
val expectedUserCodes: List<String>,

val batchJobStatus: String?,

val expectedBatchJobStatus: String?,

val expectedUserBatchJobStatus: String?,

@Searchable
val remark: String?,

val remarkDate: String?,

val remarkUuid: String?,

@Searchable
val remarkHashTags: List<String>?,

@Searchable
val assignee: String?,

val user: String?,

@Searchable
var kivIndicator: Boolean?,

@Searchable
val manualIndicator: Boolean?,

val overwrite: Boolean?

)`

GohKianSeng commented 3 months ago

just realised if i used saveAll. the Time to live is set. is that a bug?

image
bsbodden commented 3 months ago

Sounds like a bug! Did you just used save?

GohKianSeng commented 3 months ago

yes i used repository.save

GohKianSeng commented 3 months ago

hello @bsbodden for saveAll also has issue i guess.

the controller save() has TTL set.

image

but using PostConstruct doesn't work

image

Redis Insight

image
bsbodden commented 3 months ago

@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?

bsbodden commented 3 months ago

@GohKianSeng I don't think we have added support for @PostConstruct, that might be the root of the issue here

nexlink-giangbui commented 1 day ago

hello @bsbodden, I also get the same issue, the documents is saved without TTL when using save()