mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
cache
This commit is contained in:
31
cache/options.go
vendored
Normal file
31
cache/options.go
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
package cache
|
||||
|
||||
type option func(*Cache)
|
||||
|
||||
type options struct {
|
||||
Prefix string
|
||||
}
|
||||
|
||||
func WithPrefix(prefix string) option {
|
||||
return func(o *Cache) { o.prefix = prefix }
|
||||
}
|
||||
|
||||
func WithDistributdCache(d DistributdCache) option {
|
||||
return func(o *Cache) { o.distributdCache = d }
|
||||
}
|
||||
|
||||
func WithBigCache(config *BigCacheConfig) option {
|
||||
return func(o *Cache) {
|
||||
c, err := NewBigCache(config)
|
||||
_ = err
|
||||
o.mem = c
|
||||
}
|
||||
}
|
||||
|
||||
func WithFreeCache(size int) option {
|
||||
return func(o *Cache) { o.mem = NewFreeCache(size) }
|
||||
}
|
||||
|
||||
func WithPublishSubscribe(p PublishSubscribe) option {
|
||||
return func(o *Cache) {}
|
||||
}
|
Reference in New Issue
Block a user