@@ -42,10 +42,10 @@ func NewMemoryStorage(policy *serverconfigs.HTTPCachePolicy) *MemoryStorage {
4242// Init 初始化
4343func (this * MemoryStorage ) Init () error {
4444 this .list .OnAdd (func (item * Item ) {
45- atomic .AddInt64 (& this .totalSize , item .Size ())
45+ atomic .AddInt64 (& this .totalSize , item .TotalSize ())
4646 })
4747 this .list .OnRemove (func (item * Item ) {
48- atomic .AddInt64 (& this .totalSize , - item .Size ())
48+ atomic .AddInt64 (& this .totalSize , - item .TotalSize ())
4949 })
5050
5151 if this .purgeDuration <= 0 {
@@ -118,7 +118,7 @@ func (this *MemoryStorage) Delete(key string) error {
118118 hash := this .hash (key )
119119 this .locker .Lock ()
120120 delete (this .valuesMap , hash )
121- this .list .Remove (fmt .Sprintf ("%d" , hash ))
121+ _ = this .list .Remove (fmt .Sprintf ("%d" , hash ))
122122 this .locker .Unlock ()
123123 return nil
124124}
@@ -137,7 +137,7 @@ func (this *MemoryStorage) Stat() (*Stat, error) {
137137func (this * MemoryStorage ) CleanAll () error {
138138 this .locker .Lock ()
139139 this .valuesMap = map [uint64 ]* MemoryItem {}
140- this .list .Reset ()
140+ _ = this .list .Reset ()
141141 atomic .StoreInt64 (& this .totalSize , 0 )
142142 this .locker .Unlock ()
143143 return nil
@@ -173,7 +173,7 @@ func (this *MemoryStorage) Stop() {
173173 defer this .locker .Unlock ()
174174
175175 this .valuesMap = map [uint64 ]* MemoryItem {}
176- this .list .Reset ()
176+ _ = this .list .Reset ()
177177 if this .ticker != nil {
178178 this .ticker .Stop ()
179179 }
@@ -188,7 +188,7 @@ func (this *MemoryStorage) Policy() *serverconfigs.HTTPCachePolicy {
188188func (this * MemoryStorage ) AddToList (item * Item ) {
189189 item .MetaSize = int64 (len (item .Key )) + 32 /** 32是我们评估的数据结构的长度 **/
190190 hash := fmt .Sprintf ("%d" , this .hash (item .Key ))
191- this .list .Add (hash , item )
191+ _ = this .list .Add (hash , item )
192192}
193193
194194// TotalDiskSize 消耗的磁盘尺寸
0 commit comments