 
 			isExpired = (dir, index) ->
 				return false if options?.keep == dir
+				# remove any directories over the requested (non-null) limit
+				return true if options?.limit? and index > options.limit
 				# remove any directories over the hard limit
 				return true if index > OutputCacheManager.CACHE_LIMIT
 				# we can get the build time from the first part of the directory name DDDD-RRRR

					if err?
						# pass back the original files if we encountered *any* error
						callback(err, outputFiles)
					else
						# pass back the list of new files in the cache
						callback(err, results)

	archiveLogs: (outputFiles, compileDir, buildId, callback = (error) ->) ->
		archiveDir = Path.join(compileDir, OutputCacheManager.ARCHIVE_SUBDIR, buildId)

		cacheRoot = Path.join(compileDir, OutputCacheManager.CACHE_SUBDIR)
		# Put the files into a new cache subdirectory
		cacheDir = Path.join(compileDir, OutputCacheManager.CACHE_SUBDIR, buildId)
		# Is it a per-user compile? check if compile directory is PROJECTID-USERID
		perUser = Path.basename(compileDir).match(/^[0-9a-f]{24}-[0-9a-f]{24}$/)

		# Archive logs in background
		if Settings.clsi?.archive_logs or Settings.clsi?.strace
