
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
redis-structured-multi
Advanced tools
redis-structured-multi
is a Ruby library for assembling Redis's multibulk replies (from the redis-rb gem's Redis#multi
) into objects, before they're actually returned, by using promises, thunks, and fmap.
Just require redis/structured-multi
, then you can do something like this:
records = [
{:name => 'bob', :height => 180, :likes => 'carrots'},
{:name => 'phil', :height => 145, :likes => 'apples'}]
REDIS = Redis.new
full_records = REDIS.structured_multi do
records.map do |record|
last_visit = REDIS.get("user:#{record[:name]}:lastvisittime").to_i
likes = (REDIS.smembers("user:#{record[:name]}:likes") + [record[:likes]]).to_set
left_handed = REDIS.get("user:#{record[:name]}:has:hand:left")
right_handed = REDIS.get("user:#{record[:name]}:has:hand:right")
record.merge(
:last_visit => last_visit,
:likes => likes,
:has_both_hands => (left_handed && right_handed))
end
end
Under the covers, this is a single Redis pipeline. Even though we're able to do things like redis_bool && other_redis_bool
, or redis_set_members + static_set_members
, we're really just transforming promises into other promises. Here's the strategy:
structured_multi
block.After you do this, structured-multi
will actually execute the pipeline, then fmap
your structure into an equivalent one with all the same real data, but with the promises replaced with their actual Redis-retrieved values.
FAQs
Unknown package
We found that redis-structured-multi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.