From 1b8820f2e7085c750df60af0b8d42ec60db93b38 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 18 Nov 2016 11:47:16 -0500 Subject: [PATCH] Change the append build log method to execute the two calls via one pipelined connection Should reduce the amount of packets used by the build manager Reference: https://github.com/andymccurdy/redis-py#pipelines --- data/buildlogs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/buildlogs.py b/data/buildlogs.py index 90a5fd2e7..3f3336264 100644 --- a/data/buildlogs.py +++ b/data/buildlogs.py @@ -34,8 +34,11 @@ class RedisBuildLogs(object): Appends the serialized form of log_obj to the end of the log entry list and returns the new length of the list. """ - self._redis.expire(self._logs_key(build_id), SEVEN_DAYS) - return self._redis.rpush(self._logs_key(build_id), json.dumps(log_obj)) + pipeline = self._redis.pipeline(transaction=False) + pipeline.expire(self._logs_key(build_id), SEVEN_DAYS) + pipeline.rpush(self._logs_key(build_id), json.dumps(log_obj)) + result = pipeline.execute() + return result[1] def append_log_message(self, build_id, log_message, log_type=None, log_data=None): """