39 lines
631 B
Go
39 lines
631 B
Go
package zim
|
|
|
|
import "time"
|
|
|
|
type Options struct {
|
|
URLCacheSize int
|
|
URLCacheTTL time.Duration
|
|
TitleCacheSize int
|
|
TitleCacheTTL time.Duration
|
|
}
|
|
|
|
type OptionFunc func(opts *Options)
|
|
|
|
func NewOptions(funcs ...OptionFunc) *Options {
|
|
funcs = append([]OptionFunc{
|
|
WithURLCacheSize(64),
|
|
WithTitleCacheSize(64),
|
|
}, funcs...)
|
|
|
|
opts := &Options{}
|
|
for _, fn := range funcs {
|
|
fn(opts)
|
|
}
|
|
|
|
return opts
|
|
}
|
|
|
|
func WithURLCacheSize(size int) OptionFunc {
|
|
return func(opts *Options) {
|
|
opts.URLCacheSize = size
|
|
}
|
|
}
|
|
|
|
func WithTitleCacheSize(size int) OptionFunc {
|
|
return func(opts *Options) {
|
|
opts.TitleCacheSize = size
|
|
}
|
|
}
|