Spring-Data Couchbase - 如何将 TTL 设置为来自 属性 文件的文档

Spring-Data Couchbase - How to set TTL to document from property file

我正在尝试为文档设置一个 TTL,我通过放置 @Document(expiry = x sec) 了解到了这一点。但是有没有办法从 属性 文件中读取值?

这是我的依赖项:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath />
    </parent>
...
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-couchbase</artifactId>
    </dependency>

很遗憾,这还不是一项功能。如果需要灵活的TTL定义,可以在文档保存后使用touch方法: https://docs.couchbase.com/sdk-api/couchbase-java-client-2.0.0/com/couchbase/client/java/Bucket.html#touch(java.lang.String,%20int)

此外,您还可以使用标准保存方法。

最佳,