-----------------------------------------------------------------------------
(req *http.Request)
| 336 | // ----------------------------------------------------------------------------- |
| 337 | |
| 338 | func (e *rateLimiter) updateIndexCacheLOCKED(req *http.Request) { |
| 339 | // GetIndexDefs(..) without a refresh should be a fast operation |
| 340 | _, indexDefsByName, err := e.mgr.GetIndexDefs(false) |
| 341 | if err != nil { |
| 342 | return |
| 343 | } |
| 344 | |
| 345 | // Clear out the indexCache entries for all bucket:scope keys; |
| 346 | // This cache is updated with the latest subsequently. |
| 347 | e.indexCache = make(map[string]map[string]struct{}) |
| 348 | |
| 349 | for indexName, indexDef := range indexDefsByName { |
| 350 | scope, _, _ := GetScopeCollectionsFromIndexDef(indexDef) |
| 351 | key := getBucketScopeKey(indexDef.SourceName, scope) |
| 352 | if _, exists := e.indexCache[key]; !exists { |
| 353 | e.indexCache[key] = map[string]struct{}{indexName: struct{}{}} |
| 354 | } else { |
| 355 | e.indexCache[key][indexName] = struct{}{} |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | // Update index cache if request received was for deleting an index |
| 360 | // definition. |
| 361 | if req.Method != "DELETE" { |
| 362 | return |
| 363 | } |
| 364 | |
| 365 | // This is invoked prior to the index deletion, so the index definition |
| 366 | // should still be available in the system. |
| 367 | indexName := rest.IndexNameLookup(req) |
| 368 | if indexDef, exists := indexDefsByName[indexName]; exists { |
| 369 | scope, _, _ := GetScopeCollectionsFromIndexDef(indexDef) |
| 370 | key := getBucketScopeKey(indexDef.SourceName, scope) |
| 371 | if entry, exists := e.indexCache[key]; exists { |
| 372 | delete(entry, indexName) |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | func (e *rateLimiter) completeIndexRequestLOCKED(req *http.Request) { |
| 378 | if req.Method != "PUT" { |
no test coverage detected