Add TTL index creation:
Add TTL indexed for "users" and "registration" collections
This commit is contained in:
parent
9a58b5eb60
commit
cab6a429e2
@ -53,6 +53,10 @@ if corpusAge > 1036800:
|
|||||||
else:
|
else:
|
||||||
log.out('main.py: Not updating stations data', "INFO")
|
log.out('main.py: Not updating stations data', "INFO")
|
||||||
|
|
||||||
|
log.out('main.py: Requesting TTL Index Creation', "INFO")
|
||||||
|
mongo.createTtlIndex("users", "atime", 31557600)
|
||||||
|
mongo.createTtlIndex("registrations", "time", 1800)
|
||||||
|
|
||||||
# Push version number to database for reporting
|
# Push version number to database for reporting
|
||||||
mongo.putVersion(version)
|
mongo.putVersion(version)
|
||||||
|
|
||||||
|
@ -44,6 +44,11 @@ def createSingleIndex(collection, field):
|
|||||||
log.out(f'mongo.createSingleIndex: Created index of {field} in {collection}', "INFO")
|
log.out(f'mongo.createSingleIndex: Created index of {field} in {collection}', "INFO")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def createTtlIndex(collection, field, time):
|
||||||
|
col = db[collection]
|
||||||
|
col.create_index(field, expireAfterSeconds = time)
|
||||||
|
log.out(f'mongo.createTtlIndex: Created TTL Index of {field} in {collection} to expire after {time} seconds', "INFO")
|
||||||
|
|
||||||
def putBulkCorpus(data):
|
def putBulkCorpus(data):
|
||||||
collection = "corpus"
|
collection = "corpus"
|
||||||
startCount = getLength(collection)
|
startCount = getLength(collection)
|
||||||
|
Reference in New Issue
Block a user