Skip to content

Commit

Permalink
client and unit tests for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
shilparamasamyreddy committed Sep 12, 2024
1 parent 03806e9 commit cc67ad6
Show file tree
Hide file tree
Showing 10 changed files with 713 additions and 210 deletions.
6 changes: 3 additions & 3 deletions internal/cf/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func (bo *bindingFilterOwner) getListOptions() *cfclient.ServiceCredentialBindin
func (c *spaceClient) GetBinding(ctx context.Context, bindingOpts map[string]string) (*facade.Binding, error) {
if c.resourceCache.checkResourceCacheEnabled() {
// Attempt to retrieve binding from cache
if c.resourceCache.isCacheExpired("serviceBindings") {
if c.resourceCache.isCacheExpired(serviceBindings) {
//TODO: remove after internal review
fmt.Println("Cache is expired")
populateResourceCache[*spaceClient](c, "serviceBindings")
fmt.Println("Cache is expired for binding")
populateResourceCache[*spaceClient](c, serviceBindings)
}
if len(c.resourceCache.getCachedBindings()) != 0 {
binding, bindingInCache := c.resourceCache.getBindingFromCache(bindingOpts["owner"])
Expand Down
6 changes: 6 additions & 0 deletions internal/cf/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func (c *spaceClient) populateServiceInstances(ctx context.Context) error {
instanceOptions.ListOptions.LabelSelector.EqualTo(labelOwner)

cfInstances, err := c.client.ServiceInstances.ListAll(ctx, instanceOptions)
//TODO:remove later after review
fmt.Println("populate instance cache called")
if err != nil {
return err
}
Expand Down Expand Up @@ -345,6 +347,8 @@ func (c *spaceClient) populateServiceBindings(ctx context.Context) error {
bindingOptions.ListOptions.LabelSelector.EqualTo(labelOwner)

cfBindings, err := c.client.ServiceCredentialBindings.ListAll(ctx, bindingOptions)
//TODO:remove later after review
fmt.Println("populate service binding cache called")
if err != nil {
return err
}
Expand Down Expand Up @@ -376,6 +380,8 @@ func (c *organizationClient) populateSpaces(ctx context.Context) error {
spaceOptions := cfclient.NewSpaceListOptions()
spaceOptions.ListOptions.LabelSelector.EqualTo(labelOwner)

//TODO:remove later after review
fmt.Println("populate Space cache called")
cfSpaces, err := c.client.Spaces.ListAll(ctx, spaceOptions)
if err != nil {
return err
Expand Down
Loading

0 comments on commit cc67ad6

Please sign in to comment.