Files
opencloud/ocis-pkg/cache/option.go
Florian Schade 11ba46eb88 remove accounts cache from basic auth middleware
move cache to ocis-pkg
add password validation cache to accounts service
2020-11-26 13:52:24 +01:00

37 lines
552 B
Go

package cache
import "time"
// Options are all the possible options.
type Options struct {
size int
ttl time.Duration
}
// Option mutates option
type Option func(*Options)
// Size configures the size of the cache in items.
func Size(s int) Option {
return func(o *Options) {
o.size = s
}
}
// TTL rebuilds the cache after the configured duration.
func TTL(ttl time.Duration) Option {
return func(o *Options) {
o.ttl = ttl
}
}
func newOptions(opts ...Option) Options {
o := Options{}
for _, v := range opts {
v(&o)
}
return o
}