From: Space Ship Traveller Date: 2010-03-21T10:41:38+09:00 Subject: Hash#hash and detecting changes? Hello, I am writing a Rack session class. I want to detect changes to the session so that I don't write the data to the session store if the underlying hash has not changed. Right now I'm doing the following but it doesn't seem right: def call(env) load_session(env) status, headers, body = @app.call(env) commit_session(env, status, headers, body) end load_session loads env["rack.session"] from the cookie, and also saves env["rack.session"].hash into env["myframework.session.hash"] commit_session checks env["rack.session"].hash against the saved one (env["myframework.session.hash"]) and if it is different, it writes the changes to disk. The reason to do this is that writing data is expensive in this particular case, since it happens for many kinds of requests. However my understanding is that while x.hash != y.hash implies that x and y are different, x.hash == y.hash does not imply that x and y are the same. Can someone comment on this? Kind regards, Samuel