Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New realisation for thread safe history middleware #26

Merged
merged 3 commits into from
Jun 30, 2015

Conversation

davydovanton
Copy link
Owner

No description provided.

@davydovanton
Copy link
Owner Author

@mperham I added test for checking thread-safe in middleware. Also I used redis transaction (watch and multi methods) for fixing my history storage. What do you think, it's normal for you?

@mperham
Copy link
Collaborator

mperham commented Jun 30, 2015

This is safer but it's not performant at all. The issue is that you're still using Sidekiq.load_json to store a hash as a string rather than using Redis' native Hash commands. You want to use something like:

Sidekiq.redis do |c|
  c.multi do
    c.hincrby(history_key, "runtime_ms", job_time_in_ms)
    c.hmset(history_key, "last_status", "passed", "last_runtime", Time.now.utc.to_i)
  end
end

Read through the Hash commands and figure out what you need to do to remove Sidekiq.load_json.

@davydovanton
Copy link
Owner Author

Okay, I understood you, thanks for review! 🤘

@davydovanton
Copy link
Owner Author

@mperham I'll change hash serialization to native redis hash in separate PR.

davydovanton added a commit that referenced this pull request Jun 30, 2015
New realisation for thread safe history middleware
@davydovanton davydovanton merged commit 297796c into master Jun 30, 2015
@davydovanton davydovanton deleted the thread-safe-middleware branch June 30, 2015 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants