<commit_before>var cacheFactory = {
	NEVER_EXPIRES: -1,
	ONLY_DURING_EXECUTION: -2,
	MIN_CLEANUP_TIME: 10 * 60 * 1000,
	ONE_SECOND: 1000,
	ONE_MINUTE: 60 * 1000,
	ONE_HOUR: 60 * 60 * 1000,
	ONE_DAY: 24 * 60 * 60 * 1000,
	CALLBACK: 'callback',
	PROMISE: 'promise',
	
	create: function() {
		var data = {};
		var timer = 0;
		
		var self = function() {
			return self.get.apply(this, arguments);
		};
		
		var toArgs = function(args) {
			return [].slice.apply(args, []);
		};
		
		var now = function() {
			return new Date().getTime();
		};
		
		var runCleanup = function() {
			stopTimer();
			
			var date = now();
			
			for (var id in data) {
				if (!isValid(data[id], date))
					self.remove(id);
			}
			
			startTimer();
		};
		
		var stopTimer = function() {
			if (timer) {
				clearTimeout(timer);
				timer = 0;
			}
		};
		
		var startTimer = function() {
			stopTimer();
			
			var timeMs = Number.MAX_VALUE;
			
			if (self.maxAliveTimeMs > 0)
				timeMs = Math.min(timeMs, self.maxAliveTimeMs);
			
			if (self.maxNotAccessedTimeMs > 0)
				timeMs = Math.min(timeMs, self.maxNotAccessedTimeMs);
			
			if (self.onErrorMaxAliveTimeMs > 0)
				timeMs = Math.min(timeMs, self.onErrorMaxAliveTimeMs);
			
			if (timeMs !== Number.MAX_VALUE)
				timer = setTimeout(runCleanup, Math.max(timeMs, cacheFactory.MIN_CLEANUP_TIME));
		};
		
		var isValid = function(entry, date) {
			if (!entry.created)
				return false;
			
			if (entry.fetching)
				return true;
			
			if (!date)
				date = now();
			
			if (self.maxAliveTimeMs === cacheFactory.ONLY_DURING_EXECUTION || self.maxNotAccessedTimeMs === cacheFactory.ONLY_DURING_EXECUTION)
				return false;
			
			if (self.maxNotAccessedTimeMs > 0 && entry.lastTouch + self.maxNotAccessedTimeMs < date)
				return false;
			
			if (self.maxAliveTimeMs > 0 && entry.created + self.maxAliveTimeMs < date)
				return false;
			
			if (entry.args[0]) {
				if (self.onErrorMaxAliveTimeMs === cacheFactory.ONLY_DURING_EXECUTION)
					return false;
				
				if (self.onErrorMaxAliveTimeMs > 0 && entry.created + self.onErrorMaxAliveTimeMs < date)
					return false;
			}
			
			return true;
		};
		
		var getData = function(id) {
			var result = data[id];
			<commit_msg>Fixed handling of fetching on cleanup<commit_after>var cacheFactory = {
	NEVER_EXPIRES: -1,
	ONLY_DURING_EXECUTION: -2,
	MIN_CLEANUP_TIME: 10 * 60 * 1000,
	ONE_SECOND: 1000,
	ONE_MINUTE: 60 * 1000,
	ONE_HOUR: 60 * 60 * 1000,
	ONE_DAY: 24 * 60 * 60 * 1000,
	CALLBACK: 'callback',
	PROMISE: 'promise',
	
	create: function() {
		var data = {};
		var timer = 0;
		
		var self = function() {
			return self.get.apply(this, arguments);
		};
		
		var toArgs = function(args) {
			return [].slice.apply(args, []);
		};
		
		var now = function() {
			return new Date().getTime();
		};
		
		var runCleanup = function() {
			stopTimer();
			
			var date = now();
			
			for (var id in data) {
				if (!data.hasOwnProperty(id))
					continue;
				
				var entry = data[id];
				if (!isValid(entry, date) && !entry.fetching)
					self.remove(id);
			}
			
			startTimer();
		};
		
		var stopTimer = function() {
			if (timer) {
				clearTimeout(timer);
				timer = 0;
			}
		};
		
		var startTimer = function() {
			stopTimer();
			
			var timeMs = Number.MAX_VALUE;
			
			if (self.maxAliveTimeMs > 0)
				timeMs = Math.min(timeMs, self.maxAliveTimeMs);
			
			if (self.maxNotAccessedTimeMs > 0)
				timeMs = Math.min(timeMs, self.maxNotAccessedTimeMs);
			
			if (self.onErrorMaxAliveTimeMs > 0)
				timeMs = Math.min(timeMs, self.onErrorMaxAliveTimeMs);
			
			if (timeMs !== Number.MAX_VALUE)
				timer = setTimeout(runCleanup, Math.max(timeMs, cacheFactory.MIN_CLEANUP_TIME));
		};
		
		var isValid = function(entry, date) {
			if (!entry.created)
				return false;
			
			if (!date)
				date = now();
			
			if (self.maxAliveTimeMs === cacheFactory.ONLY_DURING_EXECUTION || self.maxNotAccessedTimeMs === cacheFactory.ONLY_DURING_EXECUTION)
				return false;
			
			if (self.maxNotAccessedTimeMs > 0 && entry.lastTouch + self.maxNotAccessedTimeMs < date)
				return false;
			
			if (self.maxAliveTimeMs > 0 && entry.created + self.maxAliveTimeMs < date)
				return false;
			
			if (entry.args[0]) {
				if (self.onErrorMaxAliveTimeMs === cacheFactory.ONLY_DURING_EXECUTION)
					return false;
				
				if (self.onErrorMaxAliveTimeMs > 0 && entry.created + self.onErrorMaxAliveTimeMs < date)
					return false;
			}
			
			return true;
		};
		
		var getData = function(id) {
			var result = data[id];
			
{'fraction_non_alphanumeric': 0.13036741921204073, 'fraction_numerical': 0.02080566622399292, 'mean_word_length': 2.8723221936589547, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6567991', 'n_tokens_mistral': 2102, 'n_tokens_neox': 1597, 'n_words': 350}