ttl does not work
AleCaste opened this issue · comments
Hello,
I have played around with the ttl option and I can confirm that it does NOT work.
The problem is that when the lokijs collection is created, you do it like this:
self.collection = self.client.addCollection('Sessions', {
indices: ['sid'],
ttlInterval: self.ttl
})
... which is wrong because you are setting the check interval, but you are not specifying the age.
Also, the connect-loki ttl option is supposed to be in seconds whereas the ttlInterval
is in milliseconds.
So the correct way to initialize the collection should be:
self.collection = self.client.addCollection('Sessions', {
indices: ['sid'],
ttl: self.ttl*1000, // age
ttlInterval: 5000 // interval (equal to autosaveInterval)
})
I have tested the above configuration and it does work as expected.
Please check it yourself and let me know how it goes.
Thanks!
Alex
Please also note there is an issue with the TTL capabilities of Lokijs library.
See: techfort/LokiJS#626