AddToList 添加到List
(item *Item)
| 728 | |
| 729 | // AddToList 添加到List |
| 730 | func (this *FileStorage) AddToList(item *Item) { |
| 731 | // 是否正在退出 |
| 732 | if teaconst.IsQuiting { |
| 733 | return |
| 734 | } |
| 735 | |
| 736 | var memoryStorage = this.memoryStorage |
| 737 | if memoryStorage != nil { |
| 738 | if item.Type == ItemTypeMemory { |
| 739 | memoryStorage.AddToList(item) |
| 740 | return |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | item.MetaSize = SizeMeta + 128 |
| 745 | var hash = stringutil.Md5(item.Key) |
| 746 | err := this.list.Add(hash, item) |
| 747 | if err != nil && !strings.Contains(err.Error(), "UNIQUE constraint failed") { |
| 748 | remotelogs.Error("CACHE", "add to list failed: "+err.Error()) |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | // Delete 删除某个键值对应的缓存 |
| 753 | func (this *FileStorage) Delete(key string) error { |