def get_connection(self, is_read_only=False) -> redis.StrictRedis:
if self.connection is not None:<EOL><INDENT>return self.connection<EOL><DEDENT>if self.is_sentinel:<EOL><INDENT>kwargs = dict()<EOL>if self.password:<EOL><INDENT>kwargs["<STR_LIT:password>"] = self.password<EOL><DEDENT>sentinel = Sentinel([(self.host, self.port)], **kwargs)<EOL>if is_read_only:<EOL><INDENT>connection = sentinel.slave_for(self.sentinel_service, decode_responses=True)<EOL><DEDENT>else:<EOL><INDENT>connection = sentinel.master_for(self.sentinel_service, decode_responses=True)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>connection = redis.StrictRedis(host=self.host, port=self.port, decode_responses=True,<EOL>password=self.password)<EOL><DEDENT>self.connection = connection<EOL>return connection<EOL>
Gets a StrictRedis connection for normal redis or for redis sentinel based upon redis mode in configuration.

:type is_read_only: bool
:param is_read_only: In case of redis sentinel, it returns connection to slave

:return: Returns a StrictRedis connection