保存元数据
(key string, meta *diskCacheMetadata)
| 96 | |
| 97 | // 保存元数据 |
| 98 | func (c *DiskCache) saveMetadata(key string, meta *diskCacheMetadata) error { |
| 99 | metadataFile := filepath.Join(c.path, c.getFilename(key)+".meta") |
| 100 | data, err := json.Marshal(meta) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | return ioutil.WriteFile(metadataFile, data, 0644) |
| 105 | } |
| 106 | |
| 107 | // 获取文件名 |
| 108 | func (c *DiskCache) getFilename(key string) string { |
no test coverage detected