diff --git a/.github/sponsors/apideck-dark.png b/.github/sponsors/apideck-dark.png new file mode 100644 index 00000000..1f71fdde Binary files /dev/null and b/.github/sponsors/apideck-dark.png differ diff --git a/.github/sponsors/apideck-light.png b/.github/sponsors/apideck-light.png new file mode 100644 index 00000000..60458384 Binary files /dev/null and b/.github/sponsors/apideck-light.png differ diff --git a/README.md b/README.md index 4f90a97d..2dd399eb 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,14 @@ like our _very kind_ sponsors: [scalar](https://scalar.com) + + + + apideck' + + +[apideck](https://apideck.com) --- diff --git a/index/cache.go b/index/cache.go index ba726b2c..476f82f1 100644 --- a/index/cache.go +++ b/index/cache.go @@ -9,7 +9,6 @@ import ( ) // SetCache sets a sync map as a temporary cache for the index. -// TODO: this needs to be moved to the Cache interface. func (index *SpecIndex) SetCache(sync *sync.Map) { index.cache = sync } @@ -55,8 +54,6 @@ type Cache interface { GetStore() *sync.Map AddHit() uint64 AddMiss() uint64 - SetHits(uint64) uint64 - SetMisses(uint64) uint64 GetHits() uint64 GetMisses() uint64 Clear() @@ -100,26 +97,12 @@ func (c *SimpleCache) Store(key, value any) { // AddHit increments the hit counter by one, and returns the current value of hits. func (c *SimpleCache) AddHit() uint64 { - c.hits.Add(1) - return c.hits.Load() + return c.hits.Add(1) } // AddMiss increments the miss counter by one, and returns the current value of misses. func (c *SimpleCache) AddMiss() uint64 { - c.misses.Add(1) - return c.hits.Load() -} - -// SetHits sets the hit counter to the provided value, and returns the current value of hits. -func (c *SimpleCache) SetHits(hits uint64) uint64 { - c.hits.Add(hits) - return c.hits.Load() -} - -// SetMisses sets the miss counter to the provided value, and returns the current value of misses. -func (c *SimpleCache) SetMisses(misses uint64) uint64 { - c.misses.Add(misses) - return c.misses.Load() + return c.misses.Add(1) } // GetHits returns the current value of hits. diff --git a/index/cache_test.go b/index/cache_test.go index 71aaeba4..671c27bc 100644 --- a/index/cache_test.go +++ b/index/cache_test.go @@ -61,20 +61,6 @@ func TestAddMiss(t *testing.T) { assert.Equal(t, initialMisses+1, newMisses) } -// TestSetHits tests that the hit counter is correctly set. -func TestSetHits(t *testing.T) { - cache := CreateNewCache() - cache.SetHits(10) - assert.Equal(t, uint64(10), cache.GetHits()) -} - -// TestSetMisses tests that the miss counter is correctly set. -func TestSetMisses(t *testing.T) { - cache := CreateNewCache() - cache.SetMisses(5) - assert.Equal(t, uint64(5), cache.GetMisses()) -} - // TestClear tests that the cache is correctly cleared. func TestClear(t *testing.T) { cache := CreateNewCache()