Skip to content

Commit

Permalink
fix(4.3) : transfered TTL 30 days bugfix to cb specific manager
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Jun 21, 2021
1 parent f0d103a commit 61b757d
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -69,7 +69,9 @@
*/
public class CouchbaseEntryManager extends BaseEntryManager implements Serializable {

private static final long serialVersionUID = 2127241817126412574L;
public static final int EXPIRATION_30_DAYS = 30 * 86400;

private static final long serialVersionUID = 2127241817126412575L;

private static final Logger LOG = LoggerFactory.getLogger(CouchbaseConnectionProvider.class);

Expand All @@ -87,6 +89,19 @@ protected CouchbaseEntryManager(CouchbaseOperationService operationService) {
subscribers = new LinkedList<DeleteNotifier>();
}

@Override
protected <T> Integer getExpirationValue(Object entry, Class<T> entryClass, boolean merge) {
Integer value = super.getExpirationValue(entry, entryClass, merge);

// if expiration is more then 30 days we must convert it to absolute Unit time stamp to avoid immediate expiration https://docs.couchbase.com/java-sdk/current/concept-docs/documents.html#setting-document-expiration
if (value >= EXPIRATION_30_DAYS) {
final int now = (int) System.currentTimeMillis() / 1000;
value = now + value;
}

return value;
}

@Override
public boolean destroy() {
if (this.operationService == null) {
Expand Down

0 comments on commit 61b757d

Please sign in to comment.