Pipelining متعدد Redis commands کو ایک ہی network round-trip میں بھیجتا ہے، بجائے اس کے کہ ہر command کے جواب کے لیے انتظار کریں۔ یہ بہت سی commands جاری کرتے وقت throughput میں نمایاں بہتری لاتا ہے، کیونکہ network latency — نہ کہ Redis خود — اکثر bottleneck ہوتا ہے۔
مسئلہ: round-trip latency
Normally each command is a request→reply round-trip:
send GET → wait for reply → send GET → wait for reply → ... (N × network latency)
→ Redis processes each command in microseconds, but each round-trip adds network
latency (e.g. 0.5ms). For 1000 commands, that's ~500ms JUST in waiting!
Pipelining: commands کو batch کریں
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
