S
Space Ship Traveller
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 =3D @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 !=3D y.hash implies that x =
and y are different, x.hash =3D=3D y.hash does not imply that x and y =
are the same. Can someone comment on this?
Kind regards,
Samuel=
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 =3D @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 !=3D y.hash implies that x =
and y are different, x.hash =3D=3D y.hash does not imply that x and y =
are the same. Can someone comment on this?
Kind regards,
Samuel=