Py学习  »  MongoDB

Spring数据MongoDB如何从系统属性设置索引ttl

awgtek • 4 年前 • 368 次点击  

@Indexed 注释或其他声明性方式是否可以插入系统属性,最好使用SPeL。

我试过下列方法,但发现 expireAfterSeconds

@Data
@Document(collection = "#{@xyzUpdates.collectionName}")
public class UpdatesFromXyz {

    @Id
    @Field("resourceId")
    private UUID resourceId;

    @Indexed(expireAfterSeconds = "#{@xyzUpdates.maxRecords}")
    private LocalDate updateDate;

}

我的属性类:

@ConfigurationProperties("xyz.updates")
@Getter
@Setter
@Component
public class XyzUpdates {

    private String collectionName = "updatesFromXyz";
    private int maxRecords;
}
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/54639
 
368 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Christoph Strobl
Reply   •   1 楼
Christoph Strobl    4 年前

因为SpringData MongoDB 2.2你可以使用 expireAfter