[WIP] Store Sync (#1365)

* Initial cache implementation

* Write queue implementation

* Accidentally started writing the storage sync service
This commit is contained in:
Jake Sanders
2020-03-18 16:39:36 +00:00
committed by GitHub
parent 41f8a8cb00
commit c91bf7e9e7
8 changed files with 272 additions and 54 deletions

39
store/cache/cache.go vendored
View File

@@ -1,39 +0,0 @@
package cache
import (
"github.com/micro/go-micro/v2/store"
"github.com/pkg/errors"
)
// Cache implements a cache in front of a micro Store
type Cache struct {
options store.Options
store.Store
stores []store.Store
}
// NewStore returns new cache
func NewStore(opts ...store.Option) store.Store {
s := &Cache{
options: store.Options{},
stores: []store.Store{},
}
for _, o := range opts {
o(&s.options)
}
return s
}
// Init initialises a new cache
func (c *Cache) Init(opts ...store.Option) error {
for _, o := range opts {
o(&c.options)
}
for _, s := range c.stores {
if err := s.Init(); err != nil {
return errors.Wrapf(err, "Store %s failed to Init()", s.String())
}
}
return nil
}

View File

@@ -1,15 +0,0 @@
package cache
// import "testing"
// func TestCache(t *testing.T) {
// c := NewStore()
// if err := c.Init(); err != nil {
// //t.Fatal(err)
// }
// if results, err := c.Read("test"); err != nil {
// //t.Fatal(err)
// } else {
// println(results)
// }
// }