mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	evict if new item directly is not eligible
This commit is contained in:
		
							parent
							
								
									b369953de9
								
							
						
					
					
						commit
						1cf4424870
					
				| @ -37,11 +37,15 @@ module.exports = class TTLList extends EventEmitter { | |||||||
| 
 | 
 | ||||||
|     add (value, timestamp = new Date()) { |     add (value, timestamp = new Date()) { | ||||||
|         const ttl = moment(timestamp).add(this.expireAmount, this.expireType); |         const ttl = moment(timestamp).add(this.expireAmount, this.expireType); | ||||||
|  |         if (moment().isBefore(ttl)) { | ||||||
|             this.list.add({ ttl, value }); |             this.list.add({ ttl, value }); | ||||||
|  |         } else { | ||||||
|  |             this.emit('expire', value, ttl); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     timedCheck () { |     timedCheck () { | ||||||
|         const now = moment(new Date()); |         const now = moment(); | ||||||
|         this.list.reverseRemoveUntilTrue(({ value }) => now.isBefore(value.ttl)); |         this.list.reverseRemoveUntilTrue(({ value }) => now.isBefore(value.ttl)); | ||||||
|         this.startTimer(); |         this.startTimer(); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user