<commit_before>module Iodine
	module Http
		# session management for Iodine's Http Server
		module SessionManager

			module MemSessionStorage
				@mem_storage = {}
				def self.fetch key
					@mem_storage[key] ||= {}
				end
			end
			module FileSessionStorage
				class SessionObject
					# called by the Plezi framework to initiate a session with the id requested
					def initialize id
						@filename = File.join Dir.tmpdir, "iodine_#{Iodine::Http.session_token}_#{id}"
						@data ||= {}
					end
					# Get a key from the session data store.
					#
					# Due to different considirations, all keys will be converted to strings, so that `"name" == :name` and `1234 == "1234"`.
					# If you store two keys that evaluate as the same string, they WILL override each other.
					def [] key
						key = key.to_s
						load
						@data[key]
					end
					alias :fetch :[]

					# Stores a key in the session's data store.
					#
					# Due to different considirations, all keys will be converted to strings, so that `"name" == :name` and `1234 == "1234"`.
					# If you store two keys that evaluate as the same string, they WILL override each other.
					def []= key, value
						key = key.to_s
						load
						@data[key] = value
						save
						value
					end
					alias :store :[]=

					# @return [Hash] returns a shallow copy of the current session data as a Hash.
					def to_h
						load
						@data.dup
					end

					# Removes a key from the session's data store.
					def delete key
						load
						ret = @data.delete key
						save
						ret
					end

					# Clears the session's data.
					def clear
						@data.clear
						save
						nil
					end
					protected
					def save
						# save data to tmp-file
						IO.write @filename, @data.to_yaml
					end
					def load
						@data = YAML.load IO.read(@filename) if File.exists?(@filename)
					end
				end
				def self.fetch key
					SessionObject.new key
				end
			end

			module_function<commit_msg>fix session#delete for non strings<commit_after>module Iodine
	module Http
		# session management for Iodine's Http Server
		module SessionManager

			module MemSessionStorage
				@mem_storage = {}
				def self.fetch key
					@mem_storage[key] ||= {}
				end
			end
			module FileSessionStorage
				class SessionObject
					# called by the Plezi framework to initiate a session with the id requested
					def initialize id
						@filename = File.join Dir.tmpdir, "iodine_#{Iodine::Http.session_token}_#{id}"
						@data ||= {}
					end
					# Get a key from the session data store.
					#
					# Due to different considirations, all keys will be converted to strings, so that `"name" == :name` and `1234 == "1234"`.
					# If you store two keys that evaluate as the same string, they WILL override each other.
					def [] key
						key = key.to_s
						load
						@data[key]
					end
					alias :fetch :[]

					# Stores a key in the session's data store.
					#
					# Due to different considirations, all keys will be converted to strings, so that `"name" == :name` and `1234 == "1234"`.
					# If you store two keys that evaluate as the same string, they WILL override each other.
					def []= key, value
						return delete key if value.nil?
						key = key.to_s
						load
						@data[key] = value
						save
						value
					end
					alias :store :[]=

					# @return [Hash] returns a shallow copy of the current session data as a Hash.
					def to_h
						load
						@data.dup
					end

					# @return [String] returns the Session data in YAML format.
					def to_s
						load
						@data.to_yaml
					end

					# Removes a key from the session's data store.
					def delete key
						load
						ret = @data.delete key.to_s
						save
						ret
					end

					# Clears the session's data.
					def clear
						@data.clear
						nil
					end
					protected
					# def destroy
					# 	# save data to tmp-file
					# 	File.delete @filename if ::File.file?(@filename) # && !::File.directory?(@filename)
					# end
					def save
						# save data to tmp-file
						IO.write @filename, @data.to_yaml
					end
					def load
						@data = YAML.load IO.read(@filename) if ::File.file?(@filename)
					end
				end
				def self.fetch key
					SessionObject.new key
				end
			end

			module_function
{'fraction_non_alphanumeric': 0.08092892329345532, 'fraction_numerical': 0.00750645085620455, 'mean_word_length': 2.0965867828612925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5255755', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1254, 'n_words': 489}