Skip to content

Commit

Permalink
fixup! feat: introduce a ttl cache for resources
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed May 29, 2024
1 parent 651ca1f commit fafd33c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resourcettl/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *Cache[K, R]) Checkout(key K, new func() (R, error)) (resource R, checki
c.checkouts[resourceID]++
return r, c.checkinFunc(r, resourceID), nil
}
return c.newInstance(key, new)
return c.newResource(key, new)
}

// Invalidate invalidates the resource for the given key.
Expand All @@ -98,8 +98,8 @@ func (c *Cache[K, R]) Invalidate(key K) {
}
}

// newInstance creates a new resource for the given key.
func (c *Cache[K, R]) newInstance(key K, new func() (R, error)) (R, func(), error) {
// newResource creates a new resource for the given key.
func (c *Cache[K, R]) newResource(key K, new func() (R, error)) (R, func(), error) {
r, err := new()
if err != nil {
return r, nil, err
Expand Down

0 comments on commit fafd33c

Please sign in to comment.