@@ -95,14 +95,28 @@ func (cfg *Config) Validate() error {
9595
9696// NewStore makes the storage clients based on the configuration.
9797func NewStore (cfg Config , storeCfg chunk.StoreConfig , schemaCfg chunk.SchemaConfig , limits StoreLimits ) (chunk.Store , error ) {
98- tieredCache , err := cache .New (cfg .IndexQueriesCacheConfig )
98+ indexReadCache , err := cache .New (cfg .IndexQueriesCacheConfig )
99+ if err != nil {
100+ return nil , err
101+ }
102+
103+ writeDedupeCache , err := cache .New (storeCfg .WriteDedupeCacheConfig )
104+ if err != nil {
105+ return nil , err
106+ }
107+
108+ chunkCacheCfg := storeCfg .ChunkCacheConfig
109+ chunkCacheCfg .Prefix = "chunks"
110+ chunksCache , err := cache .New (chunkCacheCfg )
99111 if err != nil {
100112 return nil , err
101113 }
102114
103115 // Cache is shared by multiple stores, which means they will try and Stop
104116 // it more than once. Wrap in a StopOnce to prevent this.
105- tieredCache = cache .StopOnce (tieredCache )
117+ indexReadCache = cache .StopOnce (indexReadCache )
118+ chunksCache = cache .StopOnce (chunksCache )
119+ writeDedupeCache = cache .StopOnce (writeDedupeCache )
106120
107121 err = schemaCfg .Load ()
108122 if err != nil {
@@ -115,7 +129,7 @@ func NewStore(cfg Config, storeCfg chunk.StoreConfig, schemaCfg chunk.SchemaConf
115129 if err != nil {
116130 return nil , errors .Wrap (err , "error creating index client" )
117131 }
118- index = newCachingIndexClient (index , tieredCache , cfg .IndexCacheValidity , limits )
132+ index = newCachingIndexClient (index , indexReadCache , cfg .IndexCacheValidity , limits )
119133
120134 objectStoreType := s .ObjectType
121135 if objectStoreType == "" {
@@ -126,7 +140,7 @@ func NewStore(cfg Config, storeCfg chunk.StoreConfig, schemaCfg chunk.SchemaConf
126140 return nil , errors .Wrap (err , "error creating object client" )
127141 }
128142
129- err = stores .AddPeriod (storeCfg , s , index , chunks , limits )
143+ err = stores .AddPeriod (storeCfg , s , index , chunks , limits , chunksCache , writeDedupeCache )
130144 if err != nil {
131145 return nil , err
132146 }
0 commit comments