GetChunk will retrieve a single chunk which belongs to a cached object or an error if it doesn't find it
(cachedObject *Object, offset int64)
| 44 | |
| 45 | // GetChunk will retrieve a single chunk which belongs to a cached object or an error if it doesn't find it |
| 46 | func (m *Memory) GetChunk(cachedObject *Object, offset int64) ([]byte, error) { |
| 47 | key := cachedObject.abs() + "-" + strconv.FormatInt(offset, 10) |
| 48 | var data []byte |
| 49 | |
| 50 | if x, found := m.db.Get(key); found { |
| 51 | data = x.([]byte) |
| 52 | return data, nil |
| 53 | } |
| 54 | |
| 55 | return nil, fmt.Errorf("couldn't get cached object data at offset %v", offset) |
| 56 | } |
| 57 | |
| 58 | // AddChunk adds a new chunk of a cached object |
| 59 | func (m *Memory) AddChunk(fp string, data []byte, offset int64) error { |