release forgets key so a subsequent request with it is processed again. Used to roll back a reservation when the reserved operation fails, so a failure is retryable rather than being mistaken for a completed duplicate.
(key string)
| 53 | // Used to roll back a reservation when the reserved operation fails, so a |
| 54 | // failure is retryable rather than being mistaken for a completed duplicate. |
| 55 | func (c *idempotencyCache) release(key string) { |
| 56 | c.mu.Lock() |
| 57 | defer c.mu.Unlock() |
| 58 | if _, ok := c.set[key]; !ok { |
| 59 | return |
| 60 | } |
| 61 | delete(c.set, key) |
| 62 | for i, k := range c.ring { |
| 63 | if k == key { |
| 64 | c.ring = append(c.ring[:i], c.ring[i+1:]...) |
| 65 | break |
| 66 | } |
| 67 | } |
| 68 | } |