Move into api routers instead of main
This commit is contained in:
29
services/entry/pkg/infrastructure/dependencies/cache.go
Normal file
29
services/entry/pkg/infrastructure/dependencies/cache.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package dependencies
|
||||
|
||||
import (
|
||||
"github.com/dgraph-io/ristretto"
|
||||
"github.com/eko/gocache/cache"
|
||||
"github.com/eko/gocache/metrics"
|
||||
"github.com/eko/gocache/store"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func setupCache(l *zap.Logger) *cache.MetricCache {
|
||||
l.Info("Setting up Cache")
|
||||
ristrettoCache, err := ristretto.NewCache(&ristretto.Config{
|
||||
NumCounters: 1000,
|
||||
MaxCost: 100_000_000,
|
||||
BufferItems: 64,
|
||||
})
|
||||
promMetrics := metrics.NewPrometheus("serverctl")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ristrettoStore := store.NewRistretto(ristrettoCache, nil)
|
||||
|
||||
cacheManager := cache.New(ristrettoStore)
|
||||
metricsCache := cache.NewMetric(promMetrics, cacheManager)
|
||||
|
||||
return metricsCache
|
||||
}
|
Reference in New Issue
Block a user