package cache import ( "time" "github.com/allegro/bigcache/v3" ) type Options struct { CacheTTL time.Duration BigCache bigcache.Config BucketCacheSize int BlobInfoCacheSize int } type OptionFunc func(opts *Options) func NewOptions(funcs ...OptionFunc) *Options { defaultTTL := 60 * time.Minute opts := &Options{ CacheTTL: defaultTTL, BigCache: bigcache.DefaultConfig(defaultTTL), BucketCacheSize: 16, BlobInfoCacheSize: 256, } for _, fn := range funcs { fn(opts) } return opts } func WithCacheTTL(ttl time.Duration) OptionFunc { return func(opts *Options) { opts.CacheTTL = ttl } } func WithBigCacheConfig(config bigcache.Config) OptionFunc { return func(opts *Options) { opts.BigCache = config } } func WithBucketCacheSize(size int) OptionFunc { return func(opts *Options) { opts.BucketCacheSize = size } } func WithBlobInfoCacheSize(size int) OptionFunc { return func(opts *Options) { opts.BlobInfoCacheSize = size } }