choose a cache deterministically based on hash of bucket,object. The hash index is treated as a hint. In the event that the cache drive at hash index is offline, treat the list of cache drives as a circular buffer and walk through them starting at hash index until an online drive is found.
(bucket, object string)
| 538 | // a hint. In the event that the cache drive at hash index is offline, treat the list of cache drives |
| 539 | // as a circular buffer and walk through them starting at hash index until an online drive is found. |
| 540 | func (c *cacheObjects) getCacheLoc(bucket, object string) (*diskCache, error) { |
| 541 | index := c.hashIndex(bucket, object) |
| 542 | numDisks := len(c.cache) |
| 543 | for k := 0; k < numDisks; k++ { |
| 544 | i := (index + k) % numDisks |
| 545 | if c.cache[i] == nil { |
| 546 | continue |
| 547 | } |
| 548 | if c.cache[i].IsOnline() { |
| 549 | return c.cache[i], nil |
| 550 | } |
| 551 | } |
| 552 | return nil, errDiskNotFound |
| 553 | } |
| 554 | |
| 555 | // get cache disk where object is currently cached for a GET operation. If object does not exist at that location, |
| 556 | // treat the list of cache drives as a circular buffer and walk through them starting at hash index |
no test coverage detected