/** * Specifies TTL in seconds. * * @param value * @return * @since 1.5 */ public Index expire(long value) { return expire(value, TimeUnit.SECONDS); }
/** * Specifies TTL in seconds. * * @param value * @return * @since 1.5 */ public Index expire(long value) { return expire(value, TimeUnit.SECONDS); }
indexDefinition.expire(index.expireAfterSeconds(), TimeUnit.SECONDS);
indexDefinition.expire(index.expireAfterSeconds(), TimeUnit.SECONDS);
/** * Method ensures that there is a TTL index on {@literal expireAt} field. It's has * {@literal expireAfterSeconds} set to zero seconds, so the expiration time is * controlled by the application. * * It can be extended in custom converters when there is a need for creating * additional custom indexes. * @param sessionCollectionIndexes {@link IndexOperations} to use */ protected void ensureIndexes(IndexOperations sessionCollectionIndexes) { for (IndexInfo info : sessionCollectionIndexes.getIndexInfo()) { if (EXPIRE_AT_FIELD_NAME.equals(info.getName())) { LOG.debug("TTL index on field " + EXPIRE_AT_FIELD_NAME + " already exists"); return; } } LOG.info("Creating TTL index on field " + EXPIRE_AT_FIELD_NAME); sessionCollectionIndexes .ensureIndex(new Index(EXPIRE_AT_FIELD_NAME, Sort.Direction.ASC).named(EXPIRE_AT_FIELD_NAME).expire(0)); }