Add GetMulti method for Cache interface

This commit is contained in:
weizili.build17
2015-06-07 21:33:01 +08:00
parent b9852df51c
commit 970f0b460c
8 changed files with 258 additions and 1 deletions

10
cache/memory.go vendored
View File

@@ -64,6 +64,16 @@ func (bc *MemoryCache) Get(name string) interface{} {
return nil
}
// GetMulti gets caches from memory.
// if non-existed or expired, return nil.
func (bc *MemoryCache) GetMulti(names []string) []interface{} {
var rc []interface{}
for _, name := range names {
rc = append(rc, bc.Get(name))
}
return rc
}
// Put cache to memory.
// if expired is 0, it will be cleaned by next gc operation ( default gc clock is 1 minute).
func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error {