Skip to content

Commit

Permalink
[refactor] - Decouple Metrics From Cache Implementation (#3355)
Browse files Browse the repository at this point in the history
* decouple metrics from cache logic

* delete

* address comments

* update
  • Loading branch information
ahrav authored Oct 4, 2024
1 parent 1e5b831 commit c98c092
Show file tree
Hide file tree
Showing 6 changed files with 617 additions and 184 deletions.
19 changes: 19 additions & 0 deletions pkg/cache/decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,22 @@ func (c *WithMetrics[T]) Clear() {
c.wrapped.Clear()
c.metrics.RecordClear(c.cacheName)
}

// Count returns the number of entries in the cache. It also records a count metric
// for the cache using the provided metrics collector and cache name.
func (c *WithMetrics[T]) Count() int {
count := c.wrapped.Count()
return count
}

// Keys returns all keys in the cache. It also records a keys metric
// for the cache using the provided metrics collector and cache name.
func (c *WithMetrics[T]) Keys() []string { return c.wrapped.Keys() }

// Values returns all values in the cache. It also records a values metric
// for the cache using the provided metrics collector and cache name.
func (c *WithMetrics[T]) Values() []T { return c.wrapped.Values() }

// Contents returns all keys in the cache as a string. It also records a contents metric
// for the cache using the provided metrics collector and cache name.
func (c *WithMetrics[T]) Contents() string { return c.wrapped.Contents() }
Loading

0 comments on commit c98c092

Please sign in to comment.