Skip to content

Commit

Permalink
chore: bump ristretto
Browse files Browse the repository at this point in the history
Breaking change: ristretto now uses generics in a breaking way. Any dependents have to also update ristretto and add the generic initializers.
  • Loading branch information
zepatrik committed Oct 18, 2024
1 parent 1f956ac commit f03ffe0
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cve-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: golang/govulncheck-action@v1
with:
go-package: ./...
go-version-input: "1.22"
go-version-input: "1.23.2"
- name: Run Trivy vulnerability scanner in repo mode
continue-on-error: true
uses: aquasecurity/trivy-action@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23.2"
- run: make format
- name: Indicate formatting issues
run: git diff HEAD --exit-code --color
2 changes: 1 addition & 1 deletion .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.22"
go-version: "1.23.2"
- uses: actions/setup-node@v2
with:
node-version: "18"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.22"
go-version: "1.23.2"
- run: |
go test -tags sqlite -failfast -short -timeout=20m $(go list ./... | grep -v sqlcon | grep -v watcherx | grep -v pkgerx | grep -v configx)
shell: bash
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.22"
go-version: "1.23.2"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
15 changes: 6 additions & 9 deletions configx/koanf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func BenchmarkKoanf(b *testing.B) {
})

b.Run("cache=true", func(b *testing.B) {
for i, c := range []*ristretto.Config{
for i, c := range []*ristretto.Config[string, any]{
{
NumCounters: int64(numKeys),
MaxCost: 500000,
Expand All @@ -104,19 +104,16 @@ func BenchmarkKoanf(b *testing.B) {
BufferItems: 64,
},
} {
cache, err := ristretto.NewCache(c)
cache, err := ristretto.NewCache[string, any](c)
require.NoError(b, err)

b.Run(fmt.Sprintf("config=%d", i), func(b *testing.B) {
var key string
var found bool
var val interface{}

b.ResetTimer()
for i := 0; i < b.N; i++ {
key = keys[i%numKeys]
for i := range b.N {
key := keys[i%numKeys]

if val, found = cache.Get(key); !found {
val, found := cache.Get(key)
if !found {
val = k.Koanf.Get(key)
_ = cache.Set(key, val, 0)
}
Expand Down
16 changes: 6 additions & 10 deletions configx/schema_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,30 @@ package configx
import (
"context"
"crypto/sha256"
"fmt"

"github.com/dgraph-io/ristretto"

"github.com/ory/jsonschema/v3"
)

var schemaCacheConfig = &ristretto.Config{
var schemaCacheConfig = &ristretto.Config[[]byte, *jsonschema.Schema]{
// Hold up to 25 schemas in cache. Usually we only need one.
MaxCost: 25,
NumCounters: 250,
BufferItems: 64,
Metrics: false,
IgnoreInternalCost: true,
Cost: func(value interface{}) int64 {
Cost: func(*jsonschema.Schema) int64 {
return 1
},
}

var schemaCache, _ = ristretto.NewCache(schemaCacheConfig)

func getSchema(ctx context.Context, schema []byte) (*jsonschema.Schema, error) {
key := fmt.Sprintf("%x", sha256.Sum256(schema))
if val, found := schemaCache.Get(key); found {
if validator, ok := val.(*jsonschema.Schema); ok {
return validator, nil
}
schemaCache.Del(key)
key := sha256.Sum256(schema)
if val, found := schemaCache.Get(key[:]); found {
return val, nil
}

schemaID, comp, err := newCompiler(schema)
Expand All @@ -46,7 +42,7 @@ func getSchema(ctx context.Context, schema []byte) (*jsonschema.Schema, error) {
return nil, err
}

schemaCache.Set(key, validator, 1)
schemaCache.Set(key[:], validator, 1)
schemaCache.Wait()
return validator, nil
}
16 changes: 6 additions & 10 deletions configx/schema_path_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package configx

import (
"crypto/sha256"
"fmt"

"github.com/ory/x/jsonschemax"

Expand All @@ -14,7 +13,7 @@ import (
"github.com/ory/jsonschema/v3"
)

var schemaPathCacheConfig = &ristretto.Config{
var schemaPathCacheConfig = &ristretto.Config[[]byte, []jsonschemax.Path]{
// Hold up to 25 schemas in cache. Usually we only need one.
MaxCost: 250,
NumCounters: 2500,
Expand All @@ -23,23 +22,20 @@ var schemaPathCacheConfig = &ristretto.Config{
IgnoreInternalCost: true,
}

var schemaPathCache, _ = ristretto.NewCache(schemaPathCacheConfig)
var schemaPathCache, _ = ristretto.NewCache[[]byte, []jsonschemax.Path](schemaPathCacheConfig)

func getSchemaPaths(rawSchema []byte, schema *jsonschema.Schema) ([]jsonschemax.Path, error) {
key := fmt.Sprintf("%x", sha256.Sum256(rawSchema))
if val, found := schemaPathCache.Get(key); found {
if validator, ok := val.([]jsonschemax.Path); ok {
return validator, nil
}
schemaPathCache.Del(key)
key := sha256.Sum256(rawSchema)
if val, found := schemaPathCache.Get(key[:]); found {
return val, nil
}

keys, err := jsonschemax.ListPathsWithInitializedSchemaAndArraysIncluded(schema)
if err != nil {
return nil, err
}

schemaPathCache.Set(key, keys, 1)
schemaPathCache.Set(key[:], keys, 1)
schemaPathCache.Wait()
return keys, nil
}
11 changes: 5 additions & 6 deletions fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import (
type Fetcher struct {
hc *retryablehttp.Client
limit int64
cache *ristretto.Cache
cache *ristretto.Cache[[]byte, []byte]
ttl time.Duration
}

type opts struct {
hc *retryablehttp.Client
limit int64
cache *ristretto.Cache
cache *ristretto.Cache[[]byte, []byte]
ttl time.Duration
}

Expand All @@ -55,7 +55,7 @@ func WithMaxHTTPMaxBytes(limit int64) Modifier {
}
}

func WithCache(cache *ristretto.Cache, ttl time.Duration) Modifier {
func WithCache(cache *ristretto.Cache[[]byte, []byte], ttl time.Duration) Modifier {
return func(o *opts) {
if ttl < 0 {
return
Expand Down Expand Up @@ -120,9 +120,8 @@ func (f *Fetcher) fetchRemote(ctx context.Context, source string) (b []byte, err
if f.cache != nil {
cacheKey := sha256.Sum256([]byte(source))
if v, ok := f.cache.Get(cacheKey[:]); ok {
cached := v.([]byte)
b = make([]byte, len(cached))
copy(b, cached)
b = make([]byte, len(v))
copy(b, v)
return b, nil
}
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestFetcher(t *testing.T) {
}))
t.Cleanup(srv.Close)

cache, err := ristretto.NewCache(&ristretto.Config{
cache, err := ristretto.NewCache[[]byte, []byte](&ristretto.Config[[]byte, []byte]{
NumCounters: 100 * 10,
MaxCost: 100,
BufferItems: 64,
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/bradleyjkemp/cupaloy/v2 v2.8.0
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cockroachdb/cockroach-go/v2 v2.3.5
github.com/dgraph-io/ristretto v0.1.1
github.com/dgraph-io/ristretto v1.0.0
github.com/docker/docker v26.1.4+incompatible
github.com/evanphx/json-patch/v5 v5.6.0
github.com/fatih/structs v1.1.0
Expand Down Expand Up @@ -116,7 +116,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -125,7 +125,7 @@ require (
github.com/docker/cli v26.1.4+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
Expand All @@ -150,7 +150,6 @@ require (
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/pprof v0.0.0-20221010195024-131d412537ea // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down Expand Up @@ -214,7 +213,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.4.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
Expand Down
23 changes: 10 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -123,10 +123,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgraph-io/ristretto v1.0.0 h1:SYG07bONKMlFDUYu5pEu3DGAh8c2OFNzKm6G9J4Si84=
github.com/dgraph-io/ristretto v1.0.0/go.mod h1:jTi2FiYEhQ1NsMmA7DeBykizjOuY88NhKBkepyu1jPc=
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/cli v26.1.4+incompatible h1:I8PHdc0MtxEADqYJZvhBrW9bo8gawKwwenxRM7/rLu8=
Expand All @@ -138,8 +138,8 @@ github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down Expand Up @@ -313,8 +313,6 @@ github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVI
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -1086,14 +1084,13 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
6 changes: 3 additions & 3 deletions jwksx/fetcher_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ type (
}
// FetcherNext is a JWK fetcher that can be used to fetch JWKs from multiple locations.
FetcherNext struct {
cache *ristretto.Cache
cache *ristretto.Cache[[]byte, jwk.Set]
}
// FetcherNextOption is a functional option for the FetcherNext.
FetcherNextOption func(*fetcherNextOptions)
)

// NewFetcherNext returns a new FetcherNext instance.
func NewFetcherNext(cache *ristretto.Cache) *FetcherNext {
func NewFetcherNext(cache *ristretto.Cache[[]byte, jwk.Set]) *FetcherNext {
return &FetcherNext{
cache: cache,
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func (f *FetcherNext) fetch(ctx context.Context, location string, opts *fetcherN
cacheKey := sha256.Sum256([]byte(location))
if opts.useCache {
if result, found := f.cache.Get(cacheKey[:]); found {
return result.(jwk.Set), nil
return result, nil
}
}

Expand Down
8 changes: 6 additions & 2 deletions jwksx/fetcher_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"testing"
"time"

"github.com/lestrrat-go/jwx/jwk"

"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"

Expand Down Expand Up @@ -59,16 +61,18 @@ func (b brokenTransport) RoundTrip(_ *http.Request) (*http.Response, error) {

func TestFetcherNext(t *testing.T) {
ctx := context.Background()
cache, _ := ristretto.NewCache(&ristretto.Config{
cache, err := ristretto.NewCache[[]byte, jwk.Set](&ristretto.Config[[]byte, jwk.Set]{
NumCounters: 100 * 10,
MaxCost: 100,
BufferItems: 64,
Metrics: true,
IgnoreInternalCost: true,
Cost: func(value interface{}) int64 {
Cost: func(jwk.Set) int64 {
return 1
},
})
require.NoError(t, err)

f := NewFetcherNext(cache)

createRemoteProvider := func(called *int, payload string) *httptest.Server {
Expand Down

0 comments on commit f03ffe0

Please sign in to comment.