2020-07-08 11:08:59 +01:00
|
|
|
// Package cache is a caching interface
|
|
|
|
package cache
|
|
|
|
|
2020-07-16 14:13:38 +01:00
|
|
|
// Cache is an interface for caching
|
2020-07-08 11:08:59 +01:00
|
|
|
type Cache interface {
|
|
|
|
// Initialise options
|
|
|
|
Init(...Option) error
|
|
|
|
// Get a value
|
|
|
|
Get(key string) (interface{}, error)
|
|
|
|
// Set a value
|
|
|
|
Set(key string, val interface{}) error
|
|
|
|
// Delete a value
|
|
|
|
Delete(key string) error
|
|
|
|
// Name of the implementation
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2020-07-16 14:13:38 +01:00
|
|
|
type Options struct {
|
|
|
|
Nodes []string
|
|
|
|
}
|
2020-07-08 14:53:38 +01:00
|
|
|
|
|
|
|
type Option func(o *Options)
|
2020-07-16 14:13:38 +01:00
|
|
|
|
|
|
|
// Nodes sets the nodes for the cache
|
|
|
|
func Nodes(v ...string) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Nodes = v
|
|
|
|
}
|
|
|
|
}
|