fix golint issues in core/collection, refine cache interface (#475)
This commit is contained in:
@@ -36,11 +36,11 @@ func (c *cachedCollection) Count(query interface{}) (int, error) {
|
||||
}
|
||||
|
||||
func (c *cachedCollection) DelCache(keys ...string) error {
|
||||
return c.cache.DelCache(keys...)
|
||||
return c.cache.Del(keys...)
|
||||
}
|
||||
|
||||
func (c *cachedCollection) GetCache(key string, v interface{}) error {
|
||||
return c.cache.GetCache(key, v)
|
||||
return c.cache.Get(key, v)
|
||||
}
|
||||
|
||||
func (c *cachedCollection) FindAllNoCache(v interface{}, query interface{}, opts ...QueryOption) error {
|
||||
@@ -125,7 +125,7 @@ func (c *cachedCollection) RemoveIdNoCache(id interface{}) error {
|
||||
}
|
||||
|
||||
func (c *cachedCollection) SetCache(key string, v interface{}) error {
|
||||
return c.cache.SetCache(key, v)
|
||||
return c.cache.Set(key, v)
|
||||
}
|
||||
|
||||
func (c *cachedCollection) Update(selector, update interface{}, keys ...string) error {
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestCollection_Count(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
|
||||
cach := cache.NewCacheNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
c := newCollection(dummyConn{}, cach)
|
||||
val, err := c.Count("any")
|
||||
assert.Nil(t, err)
|
||||
@@ -98,7 +98,7 @@ func TestStat(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
|
||||
cach := cache.NewCacheNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
c := newCollection(dummyConn{}, cach)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
@@ -121,7 +121,7 @@ func TestStatCacheFails(t *testing.T) {
|
||||
defer log.SetOutput(os.Stdout)
|
||||
|
||||
r := redis.NewRedis("localhost:59999", redis.NodeType)
|
||||
cach := cache.NewCacheNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
c := newCollection(dummyConn{}, cach)
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
@@ -142,7 +142,7 @@ func TestStatDbFails(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
|
||||
cach := cache.NewCacheNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
c := newCollection(dummyConn{}, cach)
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
@@ -164,7 +164,7 @@ func TestStatFromMemory(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
|
||||
cach := cache.NewCacheNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||
c := newCollection(dummyConn{}, cach)
|
||||
|
||||
var all sync.WaitGroup
|
||||
|
||||
@@ -34,14 +34,14 @@ func MustNewModel(url, collection string, c cache.CacheConf, opts ...cache.Optio
|
||||
}
|
||||
|
||||
func NewNodeModel(url, collection string, rds *redis.Redis, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.NewCacheNode(rds, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
c := cache.NewNode(rds, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
return createModel(url, collection, c, func(collection mongo.Collection) *cachedCollection {
|
||||
return newCollection(collection, c)
|
||||
})
|
||||
}
|
||||
|
||||
func NewModel(url, collection string, conf cache.CacheConf, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.NewCache(conf, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
c := cache.New(conf, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
return createModel(url, collection, c, func(collection mongo.Collection) *cachedCollection {
|
||||
return newCollection(collection, c)
|
||||
})
|
||||
@@ -54,11 +54,11 @@ func (mm *Model) Count(query interface{}) (int, error) {
|
||||
}
|
||||
|
||||
func (mm *Model) DelCache(keys ...string) error {
|
||||
return mm.cache.DelCache(keys...)
|
||||
return mm.cache.Del(keys...)
|
||||
}
|
||||
|
||||
func (mm *Model) GetCache(key string, v interface{}) error {
|
||||
return mm.cache.GetCache(key, v)
|
||||
return mm.cache.Get(key, v)
|
||||
}
|
||||
|
||||
func (mm *Model) GetCollection(session *mgo.Session) *cachedCollection {
|
||||
@@ -144,7 +144,7 @@ func (mm *Model) RemoveIdNoCache(id interface{}) error {
|
||||
}
|
||||
|
||||
func (mm *Model) SetCache(key string, v interface{}) error {
|
||||
return mm.cache.SetCache(key, v)
|
||||
return mm.cache.Set(key, v)
|
||||
}
|
||||
|
||||
func (mm *Model) Update(selector, update interface{}, keys ...string) error {
|
||||
|
||||
Reference in New Issue
Block a user