Skip to content

Commit

Permalink
Removed the manual cacheing mechanism (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI authored Jun 6, 2024
1 parent 1b1324a commit 91f7201
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions gcp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,17 @@ func getProject(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
}

func getProjectUncached(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
cacheKey := "getGCPProjectInfo"
var err error
var projectData *projectInfo
if cachedData, ok := d.ConnectionManager.Cache.Get(cacheKey); ok {
projectData = cachedData.(*projectInfo)
} else {
projectData, err = activeProject(ctx, d)
if err != nil {
return nil, err
}
// save to extension cache
d.ConnectionManager.Cache.Set(cacheKey, projectData)
projectData, err = activeProject(ctx, d)
if err != nil {
return nil, err
}

return projectData.Project, nil
}

func activeProject(ctx context.Context, d *plugin.QueryData) (*projectInfo, error) {
// have we already created and cached the session?
serviceCacheKey := "gcp_project_id"

if cachedData, ok := d.ConnectionManager.Cache.Get(serviceCacheKey); ok {
return cachedData.(*projectInfo), nil
}

var err error
var projectData *projectInfo
Expand Down Expand Up @@ -129,8 +117,6 @@ func activeProject(ctx context.Context, d *plugin.QueryData) (*projectInfo, erro
return nil, fmt.Errorf("an active project must be set")
}

d.ConnectionManager.Cache.Set(serviceCacheKey, projectData)

return projectData, nil
}

Expand Down

0 comments on commit 91f7201

Please sign in to comment.