2015-01-14 02:31:27 +03:00
|
|
|
package store
|
|
|
|
|
|
|
|
type Store interface {
|
2015-05-23 23:25:55 +03:00
|
|
|
Get(string) (*Item, error)
|
2015-01-14 02:31:27 +03:00
|
|
|
Del(string) error
|
2015-05-23 23:25:55 +03:00
|
|
|
Put(*Item) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type Item struct {
|
|
|
|
Key string
|
|
|
|
Value []byte
|
2015-01-14 02:31:27 +03:00
|
|
|
}
|
|
|
|
|
2015-05-16 02:34:02 +03:00
|
|
|
type options struct{}
|
|
|
|
|
2015-05-23 22:04:16 +03:00
|
|
|
type Option func(*options)
|
2015-05-16 02:34:02 +03:00
|
|
|
|
2015-01-14 02:31:27 +03:00
|
|
|
var (
|
2015-05-23 22:04:16 +03:00
|
|
|
DefaultStore = newConsulStore([]string{})
|
2015-01-14 02:31:27 +03:00
|
|
|
)
|
|
|
|
|
2015-05-23 22:04:16 +03:00
|
|
|
func NewStore(addrs []string, opt ...Option) Store {
|
|
|
|
return newConsulStore(addrs, opt...)
|
|
|
|
}
|
|
|
|
|
2015-05-23 23:25:55 +03:00
|
|
|
func Get(key string) (*Item, error) {
|
2015-01-14 02:31:27 +03:00
|
|
|
return DefaultStore.Get(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Del(key string) error {
|
|
|
|
return DefaultStore.Del(key)
|
|
|
|
}
|
|
|
|
|
2015-05-23 23:25:55 +03:00
|
|
|
func Put(item *Item) error {
|
2015-01-14 02:31:27 +03:00
|
|
|
return DefaultStore.Put(item)
|
|
|
|
}
|