updateRedis updates Redis with a new Rabbit message.
(d amqp.Delivery, c *redis.Client)
| 47 | |
| 48 | // updateRedis updates Redis with a new Rabbit message. |
| 49 | func updateRedis(d amqp.Delivery, c *redis.Client) bool { |
| 50 | // Add a message, limit to 10 in cache, increment total count. |
| 51 | if _, err := c.Pipelined(ctx, func(pipe redis.Pipeliner) error { |
| 52 | pipe.LPush(ctx, "messages", d.Body) |
| 53 | pipe.LTrim(ctx, "messages", 0, 9) |
| 54 | pipe.Incr(ctx, "total") |
| 55 | return nil |
| 56 | }); err != nil { |
| 57 | log.Fatalf("update redis: %s", err) |
| 58 | } |
| 59 | |
| 60 | return true |
| 61 | } |
no outgoing calls