@@ -56,11 +56,11 @@ func (c *TagValueSeriesIDCache) get(name, key, value []byte) *tsdb.SeriesIDSet {
5656 return nil
5757}
5858
59- // exists returns true if the an item exists for the tuple {name, key, value}.
60- func (c * TagValueSeriesIDCache ) exists (name , key , value [] byte ) bool {
61- if mmap , ok := c .cache [string ( name ) ]; ok {
62- if tkmap , ok := mmap [string ( key ) ]; ok {
63- _ , ok := tkmap [string ( value ) ]
59+ // exists returns true if the item exists for the tuple {name, key, value}.
60+ func (c * TagValueSeriesIDCache ) exists (name , key , value string ) bool {
61+ if mmap , ok := c .cache [name ]; ok {
62+ if tkmap , ok := mmap [key ]; ok {
63+ _ , ok := tkmap [value ]
6464 return ok
6565 }
6666 }
@@ -97,8 +97,13 @@ func (c *TagValueSeriesIDCache) measurementContainsSets(name []byte) bool {
9797// the cache is at its limit, then the least recently used item is evicted.
9898func (c * TagValueSeriesIDCache ) Put (name , key , value []byte , ss * tsdb.SeriesIDSet ) {
9999 c .Lock ()
100+ // Convert once; the same string backing array is shared between
101+ // the cache element (used during eviction) and the map keys.
102+ nameStr := string (name )
103+ keyStr := string (key )
104+ valueStr := string (value )
100105 // Check under the write lock if the relevant item is now in the cache.
101- if c .exists (name , key , value ) {
106+ if c .exists (nameStr , keyStr , valueStr ) {
102107 c .Unlock ()
103108 return
104109 }
@@ -109,12 +114,6 @@ func (c *TagValueSeriesIDCache) Put(name, key, value []byte, ss *tsdb.SeriesIDSe
109114 ss = ss .Clone ()
110115 }
111116
112- // Convert once; the same string backing array is shared between
113- // the cache element (used during eviction) and the map keys.
114- nameStr := string (name )
115- keyStr := string (key )
116- valueStr := string (value )
117-
118117 // Create list item, and add to the front of the eviction list.
119118 listElement := c .evictor .PushFront (& seriesIDCacheElement {
120119 name : nameStr ,
0 commit comments