File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ func (c *BigCache) Stats() Stats {
193
193
func (c * BigCache ) KeyMetadata (key string ) Metadata {
194
194
hashedKey := c .hash .Sum64 (key )
195
195
shard := c .getShard (hashedKey )
196
- return shard .getKeyMetadata (hashedKey )
196
+ return shard .getKeyMetadataWithLock (hashedKey )
197
197
}
198
198
199
199
// Iterator returns iterator function to iterate over EntryInfo's from whole cache.
Original file line number Diff line number Diff line change @@ -341,6 +341,15 @@ func (s *cacheShard) getStats() Stats {
341
341
return stats
342
342
}
343
343
344
+ func (s * cacheShard ) getKeyMetadataWithLock (key uint64 ) Metadata {
345
+ s .lock .RLock ()
346
+ c := s .hashmapStats [key ]
347
+ s .lock .RUnlock ()
348
+ return Metadata {
349
+ RequestCount : c ,
350
+ }
351
+ }
352
+
344
353
func (s * cacheShard ) getKeyMetadata (key uint64 ) Metadata {
345
354
return Metadata {
346
355
RequestCount : s .hashmapStats [key ],
You can’t perform that action at this time.
0 commit comments