ruby - Race condition with rails sessions -


there array inside session hash i'm adding things it. problem is, multiple requests processed @ same time (because ajax), , changes request makes array replaced changes made second request.

example, array first looks this:

[63, 73, 92]

then first request adds it:

[63, 73, 92, 84]

the second request same thing (but works on older version obviously):

[63, 73, 92, 102]

so in end array doesn't should. there way avoid that? tried use cache store, active record store , cookie store. same problem of them.

thanks.

there isn't great solution in rails. first suggestion examine use case , see if can avoid situation begin with. if it's safe so, session data if best kept on client, there number of challenges can come when dealing server-side session stores. on other hand, if data might useful long term across multiple page requests (and maybe multiple sessions), perhaps should go in database.

of course, there data belong in session (a example of logged-in user). if case, have @ http://paulbutcher.com/2007/05/01/race-conditions-in-rails-sessions-and-how-to-fix-them/, , https://github.com/fcheung/smart_session_store, tries deal situation you've described.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -