List of usage examples for org.springframework.data.mongodb.core.index IndexInfo getName
public String getName()
From source file:org.springframework.session.data.mongo.AbstractMongoSessionConverter.java
/** * 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.// w ww . j a v a2 s . c o m * * 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) { List<IndexInfo> indexInfo = sessionCollectionIndexes.getIndexInfo(); for (IndexInfo info : indexInfo) { 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)); }