mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2025-04-19 23:11:02 +02:00
39 lines
502 B
Go
39 lines
502 B
Go
package cache
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/grassrootseconomics/celo-tracker/internal/chain"
|
|
)
|
|
|
|
type (
|
|
Cache interface {
|
|
Purge() error
|
|
Exists(string) bool
|
|
Add(string) bool
|
|
Size() int
|
|
}
|
|
|
|
CacheOpts struct {
|
|
Logg *slog.Logger
|
|
Chain *chain.Chain
|
|
CacheType string
|
|
}
|
|
)
|
|
|
|
func New(o CacheOpts) Cache {
|
|
var (
|
|
cache Cache
|
|
)
|
|
|
|
switch o.CacheType {
|
|
case "map":
|
|
cache = NewMapCache()
|
|
default:
|
|
cache = NewMapCache()
|
|
}
|
|
o.Logg.Debug("bootstrapping cache")
|
|
|
|
return cache
|
|
}
|