Cache a successful lock for faster local lookup later
(l Lock)
| 27 | |
| 28 | // Cache a successful lock for faster local lookup later |
| 29 | func (c *LockCache) Add(l Lock) error { |
| 30 | // Store reference in both directions |
| 31 | // Path -> Lock |
| 32 | c.kv.Set(l.Path, &l) |
| 33 | // EncodedId -> Lock (encoded so we can easily identify) |
| 34 | c.kv.Set(c.encodeIdKey(l.Id), &l) |
| 35 | return nil |
| 36 | } |
| 37 | |
| 38 | // Remove a cached lock by path because it's been relinquished |
| 39 | func (c *LockCache) RemoveByPath(filePath string) error { |