Skip to content

Commit

Permalink
Change: Use redis pipeline for writing a batch of commands at once
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola authored and ArnoStiefvater committed Dec 1, 2022
1 parent 95ee9d4 commit 23adeef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rust/nvtcache/src/redisconnector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,19 @@ impl RedisCtx {
]
.to_vec();

self.kb.rpush(key_name, values)?;
// Use a pipeline for sending a command batch to redis in one single shot
let mut pipeline = pipe();
pipeline.rpush(key_name, values);

// Add preferences
let prefs = nvt.get_prefs();
if !prefs.is_empty() {
let key_name = ["oid:".to_owned(), oid.to_owned(), "prefs".to_owned()].join("");
self.kb.del(&key_name)?;
self.kb.lpush(&key_name, prefs)?;
pipeline.del(&key_name);
pipeline.lpush(&key_name, prefs);
}

pipeline.query(&mut self.kb)?;
Ok(())
}
}

0 comments on commit 23adeef

Please sign in to comment.